Find the current day, month and year in SQL Server

Have you ever wanted to return the value of the current day? Month? Or year? Well its easy in SQL and I am going to show you how.

The query for the current day is below.

SELECT DAY(GETDATE())

The query for the current month is below.

SELECT MONTH(GETDATE())

The query for the current year is below.

SELECT YEAR(GETDATE())

Each query will return a number which will correspond to the information required. For example a value of 2 returned is February in the month query.

1

Leave a comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: