如何从最后一天从数据库scadalts获取值
问题描述:
我需要从最后一天的数据库scadalts获取数据。如何从最后一天从数据库scadalts获取值
我有表中的数据pointValues哪里是列pointValue和ts但不是时间戳。
柱ts
是键入BIGINT(20)
检查TS是unixtime
SELECT
pointValue,
ts,
from_unixtime(ts),
YEAR(from_unixtime(ts)),
MONTH(from_unixtime(ts)),
DAY(from_unixtime(ts))
FROM
pointValues;
结果null
是错误的不unixtime。
我不知道如何创建条件where
,因为 - 我不知道如何解释栏ts
中的值。
答
列ts
应该更准确地解释。
如:
SELECT
pointValue,
ts,
from_unixtime(ts/1000),
YEAR(from_unixtime(ts/1000)),
MONTH(from_unixtime(ts/1000)),
DAY(from_unixtime(ts/1000))
FROM
pointValues;
而且我们可以从最后一天,如获取值:
SELECT
pointValue,
ts,
YEAR(from_unixtime(ts/1000)),
MONTH(from_unixtime(ts/1000)),
DAY(from_unixtime(ts/1000))
FROM
pointValues
WHERE
YEAR(from_unixtime(ts/1000)) = YEAR(NOW() - INTERVAL 1 day) and
MONTH(from_unixtime(ts/1000)) = MONTH(NOW() - INTERVAL 1 day) and
DAY(from_unixtime(ts/1000)) = DAY(NOW() - INTERVAL 1 day)
感谢
也许这也将
有用