How do I compare a date that goes a year back from today ? HELP

  • Hi,

    I want the condition to check : Where LastDate >= [The date from a year back today.]

    Any ideas.

    Cheers

  • Have a look in Books Online for DATEADD.

  • I still don't understand any examples please I would appreciate it thanks

  • We're not going to do all the work for you. Have a go at writing the query yourself, and if there's anything in particular you don't understand, please post again.

    John

  • (SE.LastDate >= DATEADD(m,-12,getdate()) )

    Would this get the results from 12months upto today?

  • I'll answer the question with a question..:)

    What does

    SELECT DATEADD(m,-12,getdate())

    show you?

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?

  • Yes, that looks right. If you run SELECT DATEADD(m,-12,getdate()) then you see it returns the date from a year ago. Just one thing to beware of: if your requirement is for everything from 17th March 2007 onwards to be returned (rather than everything from 14:30 on 17th March onwards) then you will need to put an extra bit of logic in to make sure it captures the whole of that day.

    John

Viewing 7 posts - 1 through 6 (of 6 total)

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