Date/Time Functions – MONTH()

I am going to remain on course with writing my series of short articles or tidbits on Transaction SQL date/time functions.

Most, if not all, modern day computer systems collect data which contains dates and times.

Not only is it important to know when a sales order came in, but we should fulfill the request using some type of queue (LIFO). If if was a stack (FIFO) implementation, the first person may never get his order!

Today, I will be exploring functions that take a datetime variable as input and return an integer as output. The MONTH() function returns an integer from 1 to 12 for valid dates.

The examples below are sample calls to the function. The inputs puts are valid date, null value and a empty string.

The output from the test is listed below. It is surprising that an empty string returns a value of 1.

To recap, this function returns the day of the month from a datetime variable in integer format.

Related posts

Leave a Comment