开发者

Recordset for todays date using CURRENT_TIMESTAMP

hopefully this is an easy one.

I have a query that I want to produce results for todays date 开发者_如何学Conly based on a column (record_date) that uses CURRENT_TIMESTAMP.

so my query goes...

Select columns FROM fields WHERE table.record_date = DATE_SUB(NOW());

This is throwing up an error... :(


Thanks for you help....So i tried....

SELECT * FROM daily_record WHERE record_date = CURDATE()

but it yielded no result.

Here is a sample of the data in the column i am searching...

2011-03-31 11:28:37, 2011-03-31 11:28:37, 2011-03-31 11:28:37, .....

Does it matter that the time is also saved?


Is that what you want ?

Select columns FROM fields WHERE table.record_date > CURDATE();


DATE_SUB() is for subtracting an interval from a date in MySQL. You've got DATE_SUB(now()), but don't specify an interval

It should be something like

... DATE_SUB(now(), INTERVAL 5 DAY);

so MySQL's complaining about the unexpected ), because of the missing interval.

If you want to convert 'now' into a date, you can simply use CURDATE(), or DATE(now())

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜