开发者

Getting MySQL data after specific date

开发者 https://www.devze.com 2022-12-13 04:27 出处:网络
How can I fetch MySQL data after a specific timestamp? What should the query look like? mysql_query(\"SELECT * FR开发者_运维技巧OM table where TheNameOfTimestampColumn > than the date\");

How can I fetch MySQL data after a specific timestamp? What should the query look like?

mysql_query("SELECT * FR开发者_运维技巧OM table where TheNameOfTimestampColumn > than the date");


SELECT * FROM table WHERE TheNameOfTimestampColumn > '2009-01-28 21:00:00'
SELECT * FROM table WHERE TheNameOfTimestampColumn > DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 1 DAY)


You can select this by :

select * from table_name where date_column > "2001-01-01 00:00:00"

or if you need data within certain time frame then you can try using between key word such as:

select * from table_name where date_column 
between "2018-01-04 00:00:00" and "2018-01-04 11:59:59";

Note that date format should be in YYYY-MM-DD HH:MM:SS


If you're using a unix timestamp, you can do the following:

SELECT * FROM table WHERE TheNameOfTimestampColumn > FROM_UNIXTIME(your_time_stamp_here)


You can use MySQL DATE function like below

For instance, if you want results after 2017-09-05

SELECT DATE(timestamp_field) as date FROM stocks_annc WHERE DATE(timestamp_field) >= '2017-09-05'

Make sure to wrap the date within single quotation ''

Hope this helps.

0

精彩评论

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