Published on: 05 Dec, 2020

TSQL Last Day of Month

Tumblr Digg Google Plus

To get the last of the month in TSQL. We can use the built in function EOMONTH. Alternatively, we can also combine the built in function of DATEADD and DATEDIFF.

See below TSQL queries for example. We are going to get the last day of current month.


SELECT EOMONTH(GETDATE()) AS LASTDAYOFMONTH

SELECT DATEADD(MONTH, 1 + DATEDIFF(MONTH, 0, GETDATE()), -1) AS LASTDAYOFMONTH

Comments

There are no comments available.

Write Comment
0 characters entered. Maximum characters allowed are 1000 characters.