mysql - SQL/PHP - Select between two dates, with date printed out -


this question has answer here:

i trying select between 2 dates in php , sql. however, php dates printed this:

july 1, 2017 

and

july 30, 2017 

the problem is, in database selecting from, dates stored yyyy-mm-dd: 2017-07-01 , 2017-07-30

i trying make query, select between 2 dates:

select dl.list_id, dl.id, dl.date, dl.list_name, dl.list_supplier, dls.reference, dls.mawb, dls.shipment, dls.kg driving_lists dl left join driving_list_shipments dls on dl.list_id = dls.list_id dl.deleted=0 , dls.kg > 0 , dl.date between 'format(july 01, 2017,'yyyy-mm-dd')' , 'format(july 30, 2017,'yyyy-mm-dd')' order dl.list_id 

so, problem this:

dl.date between 'format(july 01, 2017,'yyyy-mm-dd')' , 'format(july 30, 2017,'yyyy-mm-dd')' 

how can select between 2 dates converting format, database uses?

try date() php function
this

$date1='july 30, 2017'; $date1=date('y-m-d',strtotime($date1)); $date2='july 1, 2017'; $date2=date('y-m-d',strtotime($date2)); 

if print $date1 , $date2 like

"2017-07-30"  "2017-07-01" 

Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -