Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2002
    Location
    KY
    Posts
    56

    Unanswered: Need help With Date Query

    i'm going to put this in a if statement format so that you can understand what I'm trying to do in order to get some feed back on how to code this in a Delete Query:

    Date() = means current date(as in todays date) i want it to be standard so that i don't have to go back in and change it.

    if ( inspection_date is 3yrs < Date())

    cout << Delete from Archive Table
    else

    cout << Keep in Archive Table

    Now can somebody please help me in turning this into an expression that i can use for criteria expression in a delete query??????

  2. #2
    Join Date
    Jun 2002
    Location
    Toronto, Canada
    Posts
    7
    You could just use Date()-1095 (so, today's date minus 1,095 days)

    DELETE tblYourTable.*, tblYourTable.Inspection_Date
    FROM tblYourTable
    WHERE (((tblYourTable.Insepction_Date)=(Date()-1095)));

    You delete records where the inspection date is 1095 days ago.

  3. #3
    Join Date
    Dec 2002
    Location
    KY
    Posts
    56
    I appreciate you guys help!!!!
    Please keep on sending me some suggestions because i'm tucked out on it.




    Originally posted by eightoften
    You could just use Date()-1095 (so, today's date minus 1,095 days)

    DELETE tblYourTable.*, tblYourTable.Inspection_Date
    FROM tblYourTable
    WHERE (((tblYourTable.Insepction_Date)=(Date()-1095)));

    You delete records where the inspection date is 1095 days ago.

  4. #4
    Join Date
    Nov 2002
    Location
    Ohio
    Posts
    90
    Is the program correctily identifying records older than 3 years and failing during the delete?

    Or, is the program failing to identify records older than 3 years?

    If it correctly recognizes an "old" record, but fails to delete it, change the delete to use the key field without any references to the date:

    DELETE FROM <myTable> WHERE <myKey> = <CurrentKey>

    If is doesn't identify records older than 3 years, try testing older than 2 years. If that works, you have a Y2K problem.

    Good Luck,
    Bruce Baasch

  5. #5
    Join Date
    Dec 2002
    Location
    KY
    Posts
    56
    its failing to identify records older than 3 years?

    Originally posted by Bruce A. Baasch
    Is the program correctily identifying records older than 3 years and failing during the delete?

    Or, is the program failing to identify records older than 3 years?

    If it correctly recognizes an "old" record, but fails to delete it, change the delete to use the key field without any references to the date:

    DELETE FROM <myTable> WHERE <myKey> = <CurrentKey>

    If is doesn't identify records older than 3 years, try testing older than 2 years. If that works, you have a Y2K problem.

    Good Luck,

Posting Permissions

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