Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2002
    Location
    Southern California
    Posts
    35

    Question Unanswered: Selecting Records in a Date Range

    I'm working on a report and I need to know how to select records from a particular date range (ie: the last 30, 60, 90 days).

    I do have a date stamp in one of the tables that I'm working with.

    I've read up on the Date functions but have yet to understand how to select within a range. Any help is appreciated.

    TechRick

  2. #2
    Join Date
    Feb 2002
    Location
    Houston, TX
    Posts
    809
    use BETWEEN in your where clause and dateadd()

    select * from <your table> where <date stamp> between getdate() and dateadd(dd,-30,getdate())
    Paul Young
    (Knowledge is power! Get some!)

  3. #3
    Join Date
    Aug 2002
    Location
    Southern California
    Posts
    35

    Smile

    Originally posted by Paul Young
    use BETWEEN in your where clause and dateadd()

    select * from <your table> where <date stamp> between getdate() and dateadd(dd,-30,getdate())
    Thanks!

    For some reason I had to reverse the order to make it work but it's working great!

    where DATE_FLD between dateadd(day,-30,getdate( )) and getdate( )

    Thanks again!
    TechRick

  4. #4
    Join Date
    Feb 2002
    Location
    Houston, TX
    Posts
    809
    doh!, some time I get bass ackwards.
    Paul Young
    (Knowledge is power! Get some!)

Posting Permissions

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