Get Date - MSSQL

Get Date - MSSQL

code snippet

mssql
-- today
SELECT DATEADD(day, DATEDIFF(day, 0, GETDATE()), 0)

-- yesterday
SELECT DATEADD(day, DATEDIFF(day, 0, GETDATE()), -1)

-- start of this month
SELECT DATEADD(month, DATEDIFF(month, 0, GETDATE()), 0)

-- end of last month
SELECT DATEADD(month, DATEDIFF(month, 0, GETDATE()), -1)

-- start of next month
SELECT DATEADD(month, DATEDIFF(month, 0, GETDATE()), 31)

"Try to be a rainbow in someone's cloud"

Contact me!

Have questions? Feel free to use the form or send me an email with any questions.

I will be responsive to your requests and your questions.