Get data over a period of time with sql

I moved my CSDN to the blog garden. .

SELECT * FROM
             Table Name
            WHERE
                timestampdiff(MINUTE, SYSDATE(), send_time) <=60
            AND timestampdiff(MINUTE, SYSDATE(), send_time) >= 0

The above sql is to query the data within one hour in this table.

temestampdiff is a time function in sql that can calculate the time difference between two times

The send_time field is a field in the table.

SELECT
    enter_time,
    SYSDATE(),
    timestampdiff(HOUR, SYSDATE(), enter_time)
FROM
    ntb_event_main
WHERE
    timestampdiff(HOUR, SYSDATE(), enter_time) <= 24

AND timestampdiff(HOUR, SYSDATE(), enter_time) > 0



This is to query the records within a day in this table. All use hours instead of days. This way the data can be more accurate.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324920410&siteId=291194637