Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2009

    Unanswered: Help with Date Function please

    Hi , many thanks for your help earlier. The problem im having is that the below statement works fine in that it pulls the last 12 months data, however If I run it today, it will only include the 30th of May 2008 when infact I need all of May 2008, do you have any ideas on how I could change the query so it will always pull the full months data (ie 1st-31st May 2008 to the current date in 2009 when I run the report (i.e todays date) Many thanks for your help again

    DATEADD(mm, - 12, DATEADD(dd, DATEDIFF(d, 0, GETDATE()) + 0, 0)))

  2. #2
    Join Date
    Dec 2008
    check this is this u want
    select DATEADD(mm, - 14, DATEADD(dd, DATEDIFF(d, 0, GETDATE()) + 0, 1))

  3. #3
    Join Date
    Jun 2009
    bklr you are an absoloute Star, this has worked and is working a treat. Thanks ever so much :-0)

  4. #4
    Join Date
    Feb 2004
    In front of the computer
    Provided Answers: 54
    I'd recommend using:
    SELECT DATEADD(mm, DateDiff(mm, 0, GetDate()) - 13, 0)
    I think that the use of fourteen in the previous sample is likely to cause problems, and this code is a bit simpler.

    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts