Page 1 of 1

days between

Posted: Tue Jul 24, 2007 8:38 am
by m2babaey
Hi
I want to select data from table when the date field is between 2 special days
how should I write the where statement?

Posted: Tue Jul 24, 2007 8:54 am
by miro_igov

Code: Select all

WHERE `date_field` BETWEEN '2007-07-01' AND '2007-07-30'
This is if yuor date_field is in DATE format, if DATETIME you should add the time too. But from your posts looks like you don't try to read manuals.

Posted: Tue Jul 24, 2007 9:28 am
by impulse()
You'' probably need to use the 'date' function if the times are stored as Unix timestamps.

Posted: Tue Jul 24, 2007 10:30 am
by superdezign
miro_igov wrote:

Code: Select all

WHERE `date_field` BETWEEN '2007-07-01' AND '2007-07-30'
This is if yuor date_field is in DATE format, if DATETIME you should add the time too. But from your posts looks like you don't try to read manuals.
Hehe, quite an observation. I do notice the name coming up more often than it should. :-p

Posted: Tue Jul 24, 2007 11:38 am
by m2babaey
superdezign wrote: Hehe, quite an observation. I do notice the name coming up more often than it should. :-p
It's good i thinks.
because it means i hope to get support in DN.
posting.php?mode=reply&t=71231
but that basically because I don't know to search for what in manuals or i don't understand them. for example, someone said I may need to use date function and I looked the manual (php.net) but did not understand it.
even when I search for a function or tutorial, explanations from other sites are more understandble for me.
anyways, you have been good teachers for me. thanks

Posted: Tue Jul 24, 2007 1:14 pm
by miro_igov
Wooaaa how you search the php manual while you ask about mysql? DATE is different in MySQL but exists in PHP too.