Page 1 of 1

[SOLVED] Date Range Search

Posted: Wed Mar 16, 2005 9:02 pm
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

Posted: Wed Mar 16, 2005 9:05 pm
by feyd
why aren't you storing in MySQL's format? It's quite simple when using their format.

Posted: Thu Mar 17, 2005 12:42 pm
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 )

Posted: Thu Mar 17, 2005 2:07 pm
by feyd

Code: Select all

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