Article

How to get Month First Date and Last Date in SQL Server with Time

10 Jun 2015 Kamal Pratap
0 Comments 1475 Views



Here We explain how to get month first date and last date in sql server with time.

How to get Month First Date and Last Date in SQL Server with Time

SQL Server :

--First day of last month
SELECT DATEADD(m,-1,DATEADD(mm, DATEDIFF(m,0,GETDATE()), 0)) as StartDate
--Last day of last month
SELECT DATEADD(d,-1,DATEADD(mm, DATEDIFF(m,0,GETDATE()),0)) as EndDate
SELECT DATEADD(s, -1, DATEADD(Month, 1, DATEADD(Month, DATEDIFF(Month, 0, GETDATE()), 0))) as EndDateTime

 

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