Get first day of month using datediff


/ Published in: SQL
Save to your folder(s)

One line to determine start of previous month


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.