开发者

How retrieve next 30 days data from database? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist

Closed 9 years ago.

开发者_如何学运维 Improve this question

Please anyone can tell me the query to retrieve next 30 days data from database starting from today? Its a database users can upload upto next 90 days data.


SELECT * FROM table WHERE date >= CURRENT_TIMESTAMP AND date <= CURRENT_TIMESTAMP + INTERVAL 30 DAY


SELECT *
FROM table
WHERE date BETWEEN CURRENT_TIMESTAMP() AND DATE_ADD(CURRENT_TIMESTAMP(), INTERVAL 30 DAY)


Assuming you're storing your dates as integers (unix epoch) instead of timestamps you could do something like this:

SELECT * FROM wherever WHERE startdate >= UNIX_TIMESTAMP() AND startdate <= UNIX_TIMESTAMP() + 2592000;

This is assuming those 30 days consist of 2.592.000 seconds. Similar code is possible using the timestamps.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜