Posted By

snoopmole on 11/16/12



Versions (?)

Who likes this?

1 person have marked this snippet as a favorite


Get first day of month using datediff

 / Published in: SQL

One line to determine start of previous month

  1. declare @prevmonth datetime
  2. declare @numprevious int
  3. SET @numprevious = 2
  4. SET @prevmonth = DATEADD(month, DATEDIFF(month,0,getdate())-@numprevious,0)

Report this snippet  

You need to login to post a comment.