Results 1 to 8 of 8

Thread: Query!

  1. #1

    Thread Starter
    Member filburt1's Avatar
    Join Date
    Aug 1999
    Posts
    6,935

    Query!

    What replaces the italicized junk in this statement?
    Code:
    SELECT * FROM messages WHERE date is 30 days old or more

  2. #2
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    depends on the format of date in your table

  3. #3

    Thread Starter
    Member filburt1's Avatar
    Join Date
    Aug 1999
    Posts
    6,935
    TIMESTAMP(14)

  4. #4

    Thread Starter
    Member filburt1's Avatar
    Join Date
    Aug 1999
    Posts
    6,935
    Bumptety bump bump...

  5. #5
    scoutt
    Guest
    uhhggg I hate timestamps. makes things more difficult to chekc like you are doing.

    you could try to compare it to the current timestamp on the box. this is one way of doing it.

    PHP Code:
    // this will get the current time form the server and then make it 
    //so it looks 30 days old. then you will need to get the timestamp
    // form the DB and convert it as well.

    $dy =  date("d");
      
    $mn =  date("m");
      
    $yr date("Y");
      
    $lat 30;  
      
    $expiredate strftime("%Y.%m.%d"mktime(0,0,0,$mn,$dy-$lat,$yr));

    //then after you get the time form the DB and convert it
    // you can compare the 2, if equal then you do what you wanted to. 

  6. #6

    Thread Starter
    Member filburt1's Avatar
    Join Date
    Aug 1999
    Posts
    6,935
    Timestamps are excellent for the project I'm working on though.

    And cheeky monkey, will try that

  7. #7
    Addicted Member TheGoldenShogun's Avatar
    Join Date
    Mar 2001
    Location
    VA/MD... anywhere around the beltway
    Posts
    236
    have you tried the range thing in SQL...

    SELECT whatever from tblWhatever where tblWhatever.orderdate > '$fromyear-$frommonth-$fromday 00:00:00' and customerinfo.orderdate < '$tooyear-$toomonth-$tooday 23:59:59'

    fromyear, frommonth and fromday are just passed through a select box on the previous page but you could just capture today and add 30. Or am I totally off of what you're trying to do.
    Last edited by TheGoldenShogun; Jun 24th, 2002 at 12:21 PM.

  8. #8

    Thread Starter
    Member filburt1's Avatar
    Join Date
    Aug 1999
    Posts
    6,935
    Way off. This worked:
    Code:
    SELECT * FROM messages WHERE date<NOW() - INTERVAL 30 DAY

Posting Permissions

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



Click Here to Expand Forum to Full Width