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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.