Tuesday, June 14, 2016

SQL - First and Last Day of the current month

http://stackoverflow.com/questions/11743810/how-to-get-first-and-last-day-of-previous-month-with-timestamp-in-sql-server

 SELECT DATEADD(month, DATEDIFF(month, -1, getdate())-1, 0) as FirtDayPreviousMonthWithTimeStamp,
    DATEADD(ss, -1, DATEADD(month, DATEDIFF(month, -1, getdate()), 0)) as LastDayPreviousMonthWithTimeStamp

No comments:

Post a Comment