mysql - SQL/PHP - Select between two dates, with date printed out -
this question has answer here:
- how convert string date in mysql? 4 answers
- convert date string mysql datetime field 6 answers
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
Post a Comment