How to convert number(16,10) to date in oracle -


i'm trying read borland starteam application oracle database , noticed represent date number(16,10) column. think not timestamp or epoch. instance, have number: 37137.4347569444, how can read date?

i saw database has stored procedure, convert_date:

create or replace procedure starbase.convert_date        ( number_of_days in integer           , ndate out number)       ndateoffset number;      currentdate date;      month integer;      day integer;      year number;      success boolean := false;      bleapyear boolean:=false;     ndaysinmonths number;      nleapdays integer;      fdate number (16,10);      rgmonthdays number(5,0);  begin      select sysdate - number_of_days      currentdate      dual;      ndateoffset := 693959;      select to_number(substr((to_char (currentdate, 'mm-dd-yyyy')) , 1, 2), '99') - 1      month      dual;      select to_number(substr((to_char (currentdate, 'mm-dd-yyyy')) , 4, 2), '99') - 1      day      dual;      select to_number(substr((to_char (currentdate, 'mm-dd-yyyy')) , 7, 4), '9999')      year      dual;      if ( mod(year , 4) = 0 )          , ( ( mod(year , 400) = 0) or ( mod(year , 100) <> 0 ))              bleapyear :=true;      end if;      nleapdays := 0;      if ( bleapyear = true) , ( day = 28) , ( month = 1 )               nleapdays := 1;      end if;      select substr(to_char(last_day(currentdate) , 'dd-mm-yyyy') , 1 , 2)     ndaysinmonths      dual;      if month = 0          rgmonthdays := 0;      elsif month = 1           rgmonthdays := 31;      elsif month = 2          rgmonthdays := 59;      elsif month = 3          rgmonthdays := 90;      elsif month = 4          rgmonthdays := 120;       elsif month = 5           rgmonthdays := 151;       elsif month = 6           rgmonthdays := 181;       elsif month = 7           rgmonthdays := 212;       elsif month = 8          rgmonthdays := 243;       elsif month = 9          rgmonthdays := 273;       elsif month = 10           rgmonthdays := 304;       elsif month = 11           rgmonthdays := 334;       elsif month = 12           rgmonthdays := 365;       end if;      ndate := year*365 + year/4 - year/100 + year/400 + rgmonthdays + day + 1;       if( month < 2 ) , ( bleapyear = true)           ndate := ndate - 1;      end if;      ndate := ndate - ndateoffset;   exception       when others raise;  end convert_date; 

i don't know how use it.

how can read anyway? please help. thank you

the number 693959 clue here. number of days 1/1/00 (the year 0 never existed, digress) 12/30/1899. date used epoch older databases date represented double. should put in business:

create function float_to_date(p_days number) return date begin   return to_date('1899-12-30', 'yyyy-mm-dd') + p_days; end; 

test of course. number 37137.4347569444 should correspond 2001-09-03 10:26:03.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -