Oracle convert RAW to date format

混江龙づ霸主 提交于 2020-02-03 10:34:39

问题


I have a RAW field in my Oracle database that represents the date of user registered in system.

The value is something like 24E2321A0000000000 However I need convert the value to the date it represents (etc 2008-12-25 15:04:31).

I tried with totimestamp (see this sqlfiddle) but that didn't work.


回答1:


Maybe this will help:

SELECT utl_raw.cast_to_binary_integer('24E2321A0000000000') raw_to_int
FROM dual
/

Output is 36. I'm not sure if you need days or hours. Next example is about adding 36 hours to SYSDATE:

-- SYSDATE + 36/24 --
SELECT SYSDATE+(utl_raw.cast_to_binary_integer('24E2321A0000000000')/24) my_date
FROM dual
/

MY_DATE
---------------------
12/13/2013 4:29:22 AM



回答2:


please try one

declare
d date;
begin
   dbms_stats.convert_raw_value (hextoraw('7876070A010101'), d);
   dbms_output.put_line (d);
end;


来源:https://stackoverflow.com/questions/20462309/oracle-convert-raw-to-date-format

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!