What is the precise definition of JDE's Julian Date format?

后端 未结 8 688
清歌不尽
清歌不尽 2020-12-03 18:02

I am writing code to convert from a Gregorian date to a JDE (J.D.Edwards) Julian date.

Note: a JDE Julian date is different from the normal usag

8条回答
  •  悲哀的现实
    2020-12-03 18:26

    Save the below source code in a source member called JDEDATES. Use the runsqlstm on the first line to create the functions. You can then do things like

    select  jde2date(A1UPMJ), f.* from f00095 f                            
    

    and see a real date.

    Source:

    --RUNSQLSTM SRCFILE(qtxtsrc) SRCMBR(JDEDATES) COMMIT(*NONE)  NAMING(*SQL) 
     -- jde 2 date                                                                    
    
     create function QGPL/jde2date ( d decimal(7,0))                                  
     returns date                                                                     
     language sql                                                                     
     deterministic                                                                    
     contains sql                                                                     
        SET OPTION DATFMT=*ISO                                                        
     BEGIN                                                                            
      if d=0 then return null;                                                        
      else                                                                            
           return date(digits(decimal(d+1900000,7,0)));                               
      end if;                                                                         
     end;                                                                            -- date 2 jde                                     
     create function QGPL/date2jde ( d date)           
     returns decimal(7,0)                              
     language sql                                      
     deterministic                                     
     contains sql                                      
        SET OPTION DATFMT=*ISO                         
     BEGIN                                             
      if d is null then return 0;                      
      else                                             
      return (YEAR(D)-1900)*1000+DAYOFYEAR(D);         
      end if;                                          
     end ;                                              
    

提交回复
热议问题