我有一个日期时间字段 (P_DT),我想返回 P_DT 大于输入 unix 时间戳的所有结果.
I have a datetime field(P_DT) and I would like to return all results where P_DT is greater then an input unix timestamp.
Oracle 是否有任何可以提供帮助的内置函数?
Does Oracle have any built in functions that can help?
在我的搜索中,我找到了 DateTime 到 Unix 的结果,但没有 Unix 到 DateTime...
In my searchs I find resuts for DateTime to Unix but no Unix to DateTime...
没有内置函数.但是写一个相对容易.由于 Unix 时间戳是自 1970 年 1 月 1 日以来的秒数
There are no built-in functions. But it's relatively easy to write one. Since a Unix timestamp is the number of seconds since January 1, 1970
CREATE OR REPLACE FUNCTION unix_ts_to_date( p_unix_ts IN NUMBER )
RETURN DATE
IS
l_date DATE;
BEGIN
l_date := date '1970-01-01' + p_unix_ts/60/60/24;
RETURN l_date;
END;
你可以看到被调用
SQL> select unix_ts_to_date( 1336822620 ) from dual;
UNIX_TS_TO_DATE(133
-------------------
2012-05-12 11:37:00
这篇关于将 Unixtime 转换为日期时间 SQL (Oracle)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!