converting dates to and from fractional julian dates are *sometimes* off by a second...
I'm dealing with an application that stores dates as fractional julian dates, eg "2456037.426632" for "2012-04-19 10:14:21"
Since Oracle only works with integer Julian dates, I"ve developed a pair of functions to convert back and forth:
CREATE OR REPLACE FUNCTION "CALENDAR3"."DATE_TO_FRACTJULIAN"
(date_in IN DATE) return NUMBER is Fjdate number;
begin
select round((to_number((to_char(date_in, 'J')),'9999999') + to_number((to_char(date_in,'SSSSS')),'99999')/86400),6) into Fjdate from dual;
return (Fjdate);
end;
and
CREATE OR REPLACE FUNCTION "CALENDAR3"."FRACTJULIAN_TO_DATE"
(fjdate_in IN NUMBER) return DATE is Fj2date date;
0