End-Of-Month

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for programmers

DECLARE @D DATETIME = '2012-03-14T10:00:00'

SELECT
  CONVERT(VARCHAR(23), DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,@D),0))              , 126) as "Query in question",
  CONVERT(VARCHAR(23), DATEADD(MONTH, -1, DATEADD(DAY, 0, DATEDIFF(DAY, 0, @D)))  , 126) as "Answer by Darren",
  CONVERT(VARCHAR(23), DATEADD(DAY, -1, DATEADD(MONTH, DATEDIFF(MONTH, 0, @D), 0)), 126) as "Answer by Mikael"

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results
:records returned in :time ms:cached