Jump to content

Need rows with certain dates


subnet_rx

Recommended Posts

I have rows in a db stored with dates in the form of: 2007-07-07 00:00:00 (type is text).  I need to get all dates between now and 14 days from now.  Can I get some help on how I should do this?  Since the type is text, do I have to use strlen?  Or can I do this all in the query somehow?   

Link to comment
https://forums.phpfreaks.com/topic/77182-need-rows-with-certain-dates/
Share on other sites

How about the query:

 

SELECT * FROM `yourtable` WHERE UNIX_TIMESTAMP(`yourfield`) BETWEEN UNIX_TIMESTAMP() AND UNIX_TIMESTAMP()+60*60*24*14

 

It does beg the question of why you are storing a date in the datetime format, but in a text field - use a datetime field!

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.