Sunday, March 29, 2015

Datetime

Try:



SELECT ThisMonthMiddle=DATEADD(DD,14,CONVERT(DATE, dateadd(mm, datediff(mm,0, getdate()),0))),
LastMonthMiddle=DATEADD(MM,-1,DATEADD(DD,14,CONVERT(DATE, dateadd(mm, datediff(mm,0, getdate()),0))));
/*
2015-03-15 2015-02-15
*.

See also the EOMONTH functions: http://ift.tt/1ESLawp








Kalman Toth Database & OLAP Architect SQL Server 2014 Database Design

New Book / Kindle: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2014










No comments:

Post a Comment