Article

Start Date, End Date For Privious, Current And Next Month In SQL Server With Time Stamp

01 Jun 2018 Kamal Pratap
0 Comments 821 Views



Here we explain how to use Start Date, End Date For Privious, Current And Next Month In SQL Server With Time Stamp. This T-SQL return the start and end date with minimum and maximum time.

 

 SELECT DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE())-1, 0) as FirtDayPreviousMonthWithTimeStamp,
		DATEADD(MS, -3, DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()), 0)) as LastDayPreviousMonthWithTimeStamp

 SELECT DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()), 0) as FirtDayCurrentMonthWithTimeStamp,
		DATEADD(MS, -3, DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE())+1, 0)) as LastDayCurrentMonthWithTimeStamp

 SELECT DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE())+1, 0) as FirtDayNextMonthWithTimeStamp,
		DATEADD(MS, -3, DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE())+2, 0)) as LastDayNextMonthWithTimeStamp

 

Kamal Pratap

I have 6+ years experience in .Net technologies like Asp.Net, C#, WCF, Web Services, SQL Server, Ajax, LinQ. Currently I am working in Netcarrots Loyalty Services as a Software Developer.

Comments

No coments found to display!

Leave a Comment