Page 1 of 1

mysql search berween two date?[SOLVE]

Posted: Mon Sep 03, 2012 11:28 pm
by jayson.ph
Hi all,

I am doing some search in which my requirment is to search between specific dates.
Like user can put start date and then end date. Once submit then it should find result between these two dates but how ever how can avoid not to show the empty end date value?

Re: mysql search berween two date?

Posted: Tue Sep 04, 2012 2:37 am
by requinix
So only a start date?

Code: Select all

if ($start and $end dates) {
    date condition = "date field BETWEEN $start AND $end";
} else if (only $start) {
    date condition = "date field >= $start";
} else { // only $end
    date condition = "date field <= $end";
}

query = "SELECT ... WHERE $date condition";

Re: mysql search berween two date?[SOLVE]

Posted: Fri Sep 07, 2012 4:53 am
by jayson.ph
Thank you requinix-