Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2004
    Location
    STL
    Posts
    45

    Unanswered: subtract a year from current date

    Hey all, how do you take the current date and subtract a year from it in a SP?

    What I want to do is...

    Take the current date when the SP is ran, subtract a year, then if my date field is within that range (higher than the date with the subtracted year) it will continue in the query.

    Edit: the answer is..

    dateadd(yyyy, -1, getdate()) as Date1
    Last edited by hueby; 01-12-05 at 13:12.

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    Which DBMS are you using?

  3. #3
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    Tony, he found the answer by himself (see the "Edit" note at the bottom of his post).
    Hm, perhaps you saw it but only wanted to find out which DBMS it was?

  4. #4
    Join Date
    Aug 2004
    Location
    STL
    Posts
    45
    Ms Sql 2000

  5. #5
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    You should have posted this in that forum then. I'll move it.

  6. #6
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    Quote Originally Posted by Littlefoot
    Tony, he found the answer by himself (see the "Edit" note at the bottom of his post).
    Hm, perhaps you saw it but only wanted to find out which DBMS it was?
    No, I just didn't read it carefully enough!

  7. #7
    Join Date
    Aug 2004
    Location
    STL
    Posts
    45
    Oh, sorry.. I thought this was in the MS SQL Server forum.. my mistake.

Posting Permissions

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