【问题标题】:MySQL return only those values that comes between starttime and starttime+x valueMySQL 只返回那些介于 starttime 和 starttime+x 值之间的值
【发布时间】:2019-09-18 01:33:37
【问题描述】:

我有一种情况,在“开始时间”列中存储了 unix 时间戳。

现在,我只想选择以下记录:

currentTime = time(); // unix timestamp
currentTime >= startTime && currentTime <= (starttime + x)

其中x 是几秒的动态范围。

【问题讨论】:

    标签: mysql time compare datetime-comparison


    【解决方案1】:

    当我得到你的问题时,你需要做的是

    select * from table where xfield > UNIX_TIMESTAMP() and xfield <= SUM(UNIX_TIMESTAMP(),x);
    

    【讨论】:

    • 感谢您的回答,但我想要类似:xfield > UNIX_TIMESTAMP() 和 UNIX_TIMESTAMP()
    猜你喜欢
    • 1970-01-01
    • 2018-11-02
    • 1970-01-01
    • 2018-06-03
    • 2022-01-03
    • 1970-01-01
    • 2020-03-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多