SQL Query date problem! Help!

Results 1 to 3 of 3

Thread: SQL Query date problem! Help!

  1. #1
    Mike Cohen Guest

    Default SQL Query date problem! Help!

    Hi,<BR><BR>I&#039m trying to create a SQL statement to query my Access 97 database and retrieves records based on difference between when a record was created and today&#039s date. For example: Today&#039s date is #8/3/2000 9:14:22 AM#. I want to query records that have been inserted into the database 5 hours or more prior to the date given. The date of when the record was created is stored in the "DateCreated" field and the table is named "Log." Unfortunetly there is no DATEDIFF function in the MS Jet Engine like there is in SQL Server, so I&#039m a little stumped about what to do. Any ideas?

  2. #2
    Join Date
    Dec 1969

    Default RE: SQL Query date problem! Help!

    Use DateDiff in VBScript to calculate the start of your range, and SELECT records more recent than that...<BR><BR>Dunc

  3. #3
    Mike Cohen Guest

    Default RE: SQL Query date problem! Help!

    Found a solution that works with the DateAdd function (didn&#039t no about before). Just take the function and supply number of -5, an interval of "h" (hours) and a date. <BR><BR>NewDate = DateAdd("h", -5, "8/3/2000 11:00:00 AM")<BR><BR>NewDate equals "8/3/2000 6:00:00 AM". Now I can query any records that have a date less than NewDate.

Posting Permissions

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