Jump to content

[SOLVED] convert?


dare87

Recommended Posts

I have this query

 

SELECT title, picurl AS url, details, DATE_FORMAT(start_date, '%M %d, %Y') AS sdate, DATE_FORMAT(start_date, '%M %d, %Y') AS edate FROM giveaway WHERE start_date >= '2008-5-13' and end_date <= '2008-5-20'"

 

but I would like to change the end to

 

WHERE start_date >= NOW() and end_date <= NOW()

 

but in my db the date is stored as YYYY-MM-DD so it doesn't pull the info.

 

Please help.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/105528-solved-convert/
Share on other sites

His date is stored as a DATE and he's trying to compare it directly to a DATETIME.

 

NOW() is a DATETIME but CURDATE() is a DATE.

 

mysql> select now() = curdate();
+-------------------+
| now() = curdate() |
+-------------------+
|                 0 |
+-------------------+
1 row in set (0.00 sec)

mysql> select curdate() = curdate();
+-----------------------+
| curdate() = curdate() |
+-----------------------+
|                     1 |
+-----------------------+
1 row in set (0.00 sec)

Link to comment
https://forums.phpfreaks.com/topic/105528-solved-convert/#findComment-540986
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.