Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2007
    Posts
    1

    Unanswered: Adding 7 days to a date

    I am trying to remove data from a table in a database. Like a sort of archiving processes whereby I remove one week of data at a time.

    So I select the min date from the table (select min (TIMESTAMP) from <tblname>)

    Which returns a date in the following format -> 20070114 13:22:59.843671 +0000?

    I want to be able to add seven days to that field so I will end up with 20070121

    And then I can delete from table name where TIMESTAMP < '20070121'

    Any suggestions?

    Thanks

    Anjel

  2. #2
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    look at the dateadd function
    It seems as if your timestamp field might be a varchar so you might also need to use the convert function to convert to datetime

Posting Permissions

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