Reputation: 93
This is my request: based on Review Date
, populate the month of review in MM/DD/YYYY
format. E.g. if Review Date
is 8/17/2016, Month of Review should populate 8/1/2016.
Originally, I had it coded
datename(month, c.CreatedDate) as 'Month'
but requestor now wants it 8/1/2016
instead of 'August' regardless the day of the month.
Thank you
Upvotes: 0
Views: 67
Reputation: 465
You can use dateadd and eomonth functions
dateadd(day, 1, eomonth(dateadd(month, -1, your_date)))
EDITED
Sorry, eomonth is available since SQL Server 2012
select dateadd(day, -(datepart(day, your_date))+1, CONVERT(DATE, your_date, 101))
Upvotes: 1