SQL MONTH

The SQL MONTH() function is used to get the month (an integer in the range of 1 to 12) from a date expression.

If you need to get the year from a date, you could use the SQL YEAR Function.

SQL MONTH Syntax

SELECT MONTH(date-expression)

SQL MONTH Example

SELECT MONTH(NOW())

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

8
SELECT MONTH('2011-11-08')

The result will look like:

11

In SQL Server:

SELECT MONTH(GETDATE())

The result will look like:

8
SELECT MONTH(0)

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

1

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>