Pages

Monday, August 19, 2013

SQL SERVER – Query to Find First and Last Day of Current Month | Journey to SQL Authority with Pinal Dave

Following query will run respective to today's date. It will return Last Day of Previous Month, First Day of Current Month, Today, Last Day of Previous Month and First Day of Next Month respective to current month. DECLARE @mydate DATETIME SELECT @mydate = GETDATE() SELECT CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(@mydate)),@mydate),101) , 'Last Day of Previous Month' UNION SELECT CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(@mydate)-1),@mydate),101) AS Date_Value, 'First Day of Current Month' AS Date_Type… Continue Reading...

Source: SQL SERVER – Query to Find First and Last Day of Current Month | Journey to SQL Authority with Pinal Dave

No comments:

Post a Comment