SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Zealot amit290's Avatar
    Join Date
    Oct 2001
    Posts
    158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    find records between 2 dates (mysql query)

    can some1 plz tell what line of code do I need to put in the WHERE clause to find all records between 2 dates plz?

    PHP Code:
    $message mysql_query("SELECT * FROM wwwpages WHERE Language='$lang_choice'") or die(mysql_error()); 

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you know the dates to look between already or do you need to calulate a date.

    For alreading knowing them assuming you are using datetime fields.

    PHP Code:
    $message mysql_query("SELECT * FROM wwwpages 
    WHERE (datefield BETWEEN '
    $startdate' AND '$enddate') AND Language='$lang_choice'") or die(mysql_error()); 

    If you needed to say grab all between now and two weeks ago.

    PHP Code:
    $message mysql_query("SELECT * FROM wwwpages 
    WHERE (datefield BETWEEN DATE_SUB(NOW(), interval 2 week) AND NOW()) AND Language='
    $lang_choice'") or die(mysql_error()); 
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    SitePoint Zealot amit290's Avatar
    Join Date
    Oct 2001
    Posts
    158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thank you !!!

    it was the first example i needed. Just couldnt rememember it at all!!

    ta


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
  •