days between

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
m2babaey
Forum Contributor
Posts: 364
Joined: Sun May 20, 2007 9:26 am

days between

Post 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?
miro_igov
Forum Contributor
Posts: 485
Joined: Fri Mar 31, 2006 5:06 am
Location: Bulgaria

Post 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.
impulse()
Forum Regular
Posts: 748
Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:

Post by impulse() »

You'' probably need to use the 'date' function if the times are stored as Unix timestamps.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post 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
m2babaey
Forum Contributor
Posts: 364
Joined: Sun May 20, 2007 9:26 am

Post 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
miro_igov
Forum Contributor
Posts: 485
Joined: Fri Mar 31, 2006 5:06 am
Location: Bulgaria

Post 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.
Post Reply