building a date from getdate()

  • This should be an easy one to answer.

    I want to create a date that is the first day of the month two months in the past from the current date. In other words, if today is 7/21/2010, I want to be able to build the date value 5/1/2010. I want to use the 5/1/2010 date as the beginning date in a date range and the current date as the last day in the date range. My date range would be 5/1/2010 to /7/21/2010.

    I have been having fits getting this to work. Any and all ideas would be appreciated.

    Thanks.

    Ralph

  • https://qa.sqlservercentral.com/blogs/lynnpettis/archive/2009/03/25/some-common-date-routines.aspx

    Good article by Lynn Pettis above that should get you started

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

  • Something like this?

    SELECT DATEADD(MONTH,DATEDIFF(MONTH,0,GETDATE())-2 ,0),GETDATE()



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply