Results 1 to 5 of 5

Thread: Date Question

  1. #1
    Join Date
    May 2009
    Posts
    104

    Unanswered: Date Question

    Is if possible to return all records that occur before the current month. Right now i have a query That says

    SELECT GageList.GageNumber, GageList.GageDescription, GageList.GageSize, GageList.CalibrationDate
    FROM GageList
    WHERE (((Year([CalibrationDate]))<Year(Now())) AND ((Month([CalibrationDate]))<Month(Now())));

    But this doesn't return all of the results.

    This does

    SELECT GageList.GageNumber, GageList.GageDescription, GageList.GageSize, GageList.CalibrationDate
    FROM GageList
    WHERE (((GageList.CalibrationDate)<Now()));

    But only because i dont have any records for this month. I don't want to include this month in the query.
    Thoughts?
    Last edited by dbshaft; 06-08-09 at 16:32.

  2. #2
    Join Date
    Feb 2004
    Posts
    214

    ...

    Date()-Day(Date())
    You know, I'm sick of following my dreams, man. I'm just going to ask where they're going and hook up with 'em later

  3. #3
    Join Date
    May 2009
    Posts
    104
    I recoded like this

    SELECT GageList.GageNumber, GageList.GageDescription, GageList.GageSize, GageList.CalibrationDate
    FROM GageList
    WHERE (((GageList.CalibrationDate)=Date()-Day(Date())));

    And i don't return any results at all now.

  4. #4
    Join Date
    Feb 2004
    Posts
    214

    ...

    Date()-Day(Date()) returns the last day of the previous month. So instead, you should be using <= otherwise you are asking for records with a date of 5/31/09 only and not everything before June 1.

    WHERE (((GageList.CalibrationDate)<=Date()-Day(Date())))
    You know, I'm sick of following my dreams, man. I'm just going to ask where they're going and hook up with 'em later

  5. #5
    Join Date
    May 2009
    Posts
    104
    That makes sense. That worked beautifully. Thank you.

Posting Permissions

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