http://www.itwenzhai.com/data/2006/0523/article_8484.htm
CREATE OR REPLACE FUNCTION unix_to_oracle(in_number NUMBER)
RETURN DATE
IS
BEGIN
RETURN TO_DATE('19700101','yyyymmdd') + in_number/86400 +TO_NUMBER(SUBSTR(TZ_OFFSET(sessiontimezone),1,3))/24;
END;
/
CREATE OR REPLACE FUNCTION oracle_to_unix(in_date IN DATE)
RETURN NUMBER
IS
BEGIN
RETURN (in_date -TO_DATE('19700101','yyyymmdd'))*86400 -
TO_NUMBER(SUBSTR(TZ_OFFSET(sessiontimezo
ne),1,3))*3600;
END;
/
CREATE OR REPLACE FUNCTION unix_to_oracle(in_number NUMBER)
RETURN DATE
IS
BEGIN
RETURN TO_DATE('19700101','yyyymmdd') + in_number/86400 +TO_NUMBER(SUBSTR(TZ_OFFSET(sessiontimezone),1,3))/24;
END;
/
CREATE OR REPLACE FUNCTION oracle_to_unix(in_date IN DATE)
RETURN NUMBER
IS
BEGIN
RETURN (in_date -TO_DATE('19700101','yyyymmdd'))*86400 -
TO_NUMBER(SUBSTR(TZ_OFFSET(sessiontimezo
ne),1,3))*3600;
END;
/
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/936/viewspace-60697/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/936/viewspace-60697/