Forum Moderators: coopster

Message Too Old, No Replies

Getting Results according to dates

select count(idc) as idc from reservations where Logtime between 2 dates...

         

omoutop

1:26 pm on Sep 9, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi to all!
I need your wisdom for one more time....

I have a field in my database called 'Logtime' which stores dates in format "2005-09-09 14:55:30"...

I have a form in which i can select two dates (via javascript...small calendar) and i need to query the database to find the total number of records where the Logtime is between the two dates which I posted....

Dates from javascript are in this format : 2005-08-01 ....
is there any way I can do it? something like this?

select count(idc) as idc from reservations where Logtime > $date1 and Logtime < $date2....

plz help me...
thx in advance

omoutop

1:44 pm on Sep 9, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



hi again...I tried this way

select count(idc) as idc from reservations where Logtime <= '$date2' and Logtime >= '$date1'

and it works....hard to say if results are fine in a 90.944 records database....

is this a common way to get results acoording to dates?

coopster

3:42 pm on Sep 9, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Sure. Or use BETWEEN:

select count(idc) as idc from reservations where Logtime BETWEEN '$date1' AND '$date2'

To speed things up, you may eventually end up creating an index on the reservations table by "Logtime".