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

后端 未结 8 690
清歌不尽
清歌不尽 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:30

    Wow, there's a lot of complicated code in some of these answers just to convert to and from JDE julian dates. There are simple ways in Excel and VBA to get there.

    FROM JULIAN

    Excel (assuming julian date is in A1):

    =DATE(1900+LEFT(A1,LEN(A1)-3),1,RIGHT(A1,3))
    

    VBA (from julian date, j, stored as String):

    d = DateSerial(1900 + Left$(j, Len(j) - 3), 1, Right$(j, 3))
    

    VBA (from julian date, j, stored as Long):

    d = DateSerial(1900 + Left$(j, Len(CStr(j)) - 3), 1, Right$(j, 3))
    

    TO JULIAN

    Excel (assuming date is in A1):

    =(YEAR(A1)-1900)*1000+A1-DATE(YEAR(A1),1,0)
    

    VBA (to a Long, j):

    j = (Year(d) - 1900) * 1000 + DatePart("y", d)
    

提交回复
热议问题