Page 1 of 1
Date Between And
Posted: Sun Feb 15, 2004 8:51 am
by glennalmeda
Code: Select all
$sqlQty = "SELECT * FROM sales_invoice WHERE company = '$company' AND date BETWEEN '$frmDate' AND '$ThruDate' AND payment_status = 'Paid'";
this is my code to get fields between two dates..
but i cant get the data if i input two same dates.
for example:
Code: Select all
$frmDate = 2004-02-12
$ThruDate = 2004-02-12
because i want to get the data for the current date...
let say today is feb 12, i can only get the data for that day if the date i input are 2004-02-12 to 2004-02-13.
what should be my sql statement...? thanks
Posted: Sun Feb 15, 2004 9:27 am
by microthick
You might be able to add the time to those date strings.
Like:
$fromdate = "2004-02-12 00:00:00";
$todate = "2004-02-12 11:59:59";
Posted: Sun Feb 15, 2004 1:19 pm
by JAM
Code: Select all
select * from test where date between '2004-03-03' and '2004-03-04'
Worked for me using DATE fieldtypes. I got two hits. If I change the DATE to DATETIME, and added a second to the later (2004-03-04 00:00:01), then it failed (only one hit).
If you are not using DATE as fieldtypes, you likely have this issue. You should however be able to use cast/convert to bypass it.