复制代码 代码如下:
mysql> select from_unixtime(1, '%Y-%m-%d %H:%i:%S');
+---------------------------------------+
| from_unixtime(1, '%Y-%m-%d %H:%i:%S') |
+---------------------------------------+
| 1970-01-01 08:00:01 |
+---------------------------------------+
1 row in set (0.00 sec)
复制代码 代码如下:
SQL> create or replace function long2date (param in long) return varchar2 as
v_text varchar2(64);
2 begin
3 select to_char(to_date('1970-01-01', 'YYYY-MM-DD')+(param/(24*60*60*1000)+
8/24-1/86400),'YYYY-MM-DD HH24:MI:SS')
4 into v_text from dual;
5 return v_text;
6 end long2date;
7 /
函数已创建。
SQL> select long2date(1000) from dual;
LONG2DATE(1000)
--------------------------------------------------------------------------------------
1970-01-01 08:00:00
SQL> select to_char(sysdate, 'YYYY-MM-DD HH24:MI:SS') char_sysdate, long2date(
(sysdate - 8/24 - to_date('1970-01-01','YYYY-MM-DD')) * 86400000) long2date from dual;
CHAR_SYSDATE LONG2DATE
------------------- --------------------
2013-01-07 14:53:18 2013-01-07 14:53:17
复制代码 代码如下:
SQL> col current_milli format 999999999999999;
SQL> select to_char(sysdate, 'YYYY-MM-DD HH24:MI:SS') current_date, (sysdate -
to_date('1970-01-01', 'YYYY-MM-DD'))* 86400000 current_milli from dual;
CURRENT_DATE CURRENT_MILLI
------------------- ----------------
2013-01-07 15:09:18 1357571358000
新闻热点
疑难解答