Jump to content

PHP/mysql - WHERE date is smaller than...


daydreamer

Recommended Posts

I need to select a bunch of rows that are either before or after given dates.

 

The way I was going to do it is to Select *, and then a while loop which checks the dates are bigger or smaller than the given date.

 

Is it possible to do it directly from the mysql statement.

 

eg:

"SELECT * FROM table WHERE date>'$givenfromdate' AND date<'$giventodate'"

 

The dates stored in the mysql table are in this format:

2008-12-26 17:32:34

 

So how could I do this? In the while loop I would just convert both dates to the mktime format and compare to see which is biggest - is it possible to also convert the dates to the mktime format in the mysql statement?

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/138496-phpmysql-where-date-is-smaller-than/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.