Advanced Search

Results 1 to 2 of 2

Thread: Selecting a time range

  1. #1
    Join Date
    Dec 2007
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Selecting a time range

    Hi gang. Ima Newbie and stuck. I'm trying to display active records in a table on my web page. However, to minimize maintenance, I only want to display records that are up to 48 hours old at any point. Here's my code so far:
    Code:
    $query="SELECT * from birthdays where Active='1' AND Event='request' AND hour(DateEntered)< 48";
    Where "Active" is a flag at 1/0..."Event" is populated and "DateEntered" is a system TimeStamp of the record creation.

    I have 11 Active records total that are active and 5 that are active AND 48 hours old, or less, so my page should return 5 records. It's returning all 11.

    Any help?

  2. #2
    Join Date
    Dec 2007
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Code:
    $query="SELECT * from birthdays where Active='1' AND Event='request' AND DateEntered > (NOW()-86400*2)";
    Was the answer. Got it fixed. Thanks all

Bookmarks

Posting Permissions

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