1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to compare dates in PHP ,MySQL?

Discussion in 'PHP' started by kks_krishna, Jul 6, 2007.

  1. #1
    HI,

    I am having problem in comparing dates.

    $query = "SELECT * FROM table_name WHERE date > '07/01/2007' and date < '07/30/2007' order by id desc ";

    What is the problem in the query?
     
    kks_krishna, Jul 6, 2007 IP
  2. Gangsta

    Gangsta Active Member

    Messages:
    145
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #2
    why not to use timestamp format of mysql fields?

     
    Gangsta, Jul 6, 2007 IP
  3. mushroom

    mushroom Peon

    Messages:
    369
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #3
    When dealing with date or time ranges you should use "BETWEEN" not "> and <"

    where date BETWEEN 'start_date' and 'end_date'
    PHP:
     
    mushroom, Jul 6, 2007 IP
    ansi likes this.
  4. kks_krishna

    kks_krishna Active Member

    Messages:
    1,495
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    80
    #4
    Thanks for the help.
     
    kks_krishna, Jul 7, 2007 IP