[SOLVED] Date Range Search

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
Cronikeys
Forum Commoner
Posts: 35
Joined: Sun Jan 16, 2005 9:14 am

[SOLVED] Date Range Search

Post by Cronikeys »

Hello :)

I have a question about date range searching... aka from one date to another date display all entries that fall within those ;)

Currently my code inputs the date like this into the MySQL: 3/16/05

I realize it would require some substringing and stuff, but how exactly would it work? I have figured out how to make things show up that are before or after a date, but not between to dates ;)

My code is VERY flexible, so I don't really see a point in pasting it here... basically I have none of this done, because I don't even see how it is done :( if the 3/16/05 date string isn't proper format will someone also explain how to do this properly.

Thanks
Last edited by Cronikeys on Thu Mar 17, 2005 6:06 pm, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

why aren't you storing in MySQL's format? It's quite simple when using their format.
Cronikeys
Forum Commoner
Posts: 35
Joined: Sun Jan 16, 2005 9:14 am

Post by Cronikeys »

Let's say I was using that format, would it just be this:

if($articledate >= $lowdate && $articledate <= $highdate)

?

Thanks :)

(I will change the code soon ;) I wrote the date snippet of the code back when I was a n00b (I guess I still am a n00b :( lol )
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

... `date_field` BETWEEN '2004-03-18' AND '2005-03-17' ...
Post Reply