Home Forums SQL Server 2008 T-SQL (SS2K8) How To return Year & Month in this format: 2013-06 RE: How To return Year & Month in this format: 2013-06

  • I like that answer, thanks for sharing. I know some may find that logic hard to follow, at least some that I know. 🙂 We have always used the following code to get the first of the month. Of course you would replace the getdate() with the date from your table.

    select DATEADD(dd, -(DATEPART(dd, GETDATE())) +1, convert(char(10), GETDATE(), 101))

    -------------------------------------------------------------
    we travel not to escape life but for life not to escape us
    Don't fear failure, fear regret.