Select data between two dates?

后端 未结 5 413
灰色年华
灰色年华 2020-12-06 08:46

I\'m using a database to store logs, with a column \"date\" which holds the date it was inserted. The format of the date is \"MM/DD/YY\". Please can anyone suggest how I wou

5条回答
  •  无人及你
    2020-12-06 09:19

    You need to add single quotes to the date values '01/01/12':

    $from_date = "01/01/12";
    $to_date = "02/11/12";
    
    $result = mysql_query("SELECT * FROM logs WHERE date >= '" . $from_date . "' AND date <= '" . $to_date . "' ORDER by id DESC");
    

提交回复
热议问题