About You - Tools - Profile - Gallery


http://www.heelpbook.net/feed   Valid RSS (HeelpBook) - visit http://www.heelpbook.com/feed   http://www.heelpbook.com/feed
   
 
SQL Server - Query to Find First and Last Day of Current Month –> (Word) SQL Server - Query to Find First and Last Day of Current Month –> (PDF) SQL Server - Query to Find First and Last Day of Current Month –> (Epub)
This article has been published 5 years, 59 days ago

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
UNION
SELECT CONVERT(VARCHAR(25),@mydate,101) AS Date_Value, 'Today' AS Date_Type
UNION
SELECT CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(DATEADD(mm,1,@mydate))),DATEADD(mm,1,@mydate)),101) ,
'Last Day of Current Month'
UNION
SELECT CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(DATEADD(mm,1,@mydate))-1),DATEADD(mm,1,@mydate)),101) ,
'First Day of Next Month'
GO
SOURCE

LINK (Sqlauthority.com)

LANGUAGE
ENGLISH
SQL Server - Query to Find First and Last Day of Current Month SQL Server - Query to Find First and Last Day of Current Month
Facebook Twitter Email Plusone Linkedin Stumbleupon Delicious Digg
   
© 2011 - 2013 HeelpBook - Today is: 28/3/2017 Last updated: June 5, 2013 at 8:07 am Get helped -
+ +