SQL DAY

The SQL DAY() function is used to get the day (an integer in the range of 1 to 31) from a date expression.

To get the year from a date: SQL YEAR Function.
To get the month from a date: SQL Month Function.
To get the day from a date: SQL Day Function.

SQL DAY Syntax

SELECT DAY(date-expression)

SQL DAY Example

SELECT DAY(NOW())

The result will look like: (Suppose it’s August 22, 2011 now)

22
SELECT DAY('2011-12-23')

The result will look like:

23

In SQL Server:

SELECT DAY(GETDATE())

The result will look like:

22
SELECT DAY(0)

The result will look like: (which is the base day)

1

Leave a Comment