Skip to content

Instantly share code, notes, and snippets.

@bkono
Created August 23, 2010 23:46
Show Gist options
  • Save bkono/546581 to your computer and use it in GitHub Desktop.
Save bkono/546581 to your computer and use it in GitHub Desktop.
--'First Day of Last Month, and Last Day of Last Month'
declare @MyDate smalldatetime
set @MyDate = DATEADD(Month, -1, GETDATE())
SELECT CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(@mydate)-1),@mydate),101)
set @MyDate = GETDATE()
SELECT CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(@mydate)),@mydate),101)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment