JD EDWARDS (AS/400 software) uses dates called JULIAN.
A JULIAN Date identifies the year first, then the number of days into the year that this
date appears. So, Jan 15, 1999 is 99015. March 15 is 99074. March 15, 2001 is 101074 Dates
in Y2K start with 100 (2000), 101(2001) etc.
CONVERT DATE TO JULIAN
Private Sub ConvertToJul()
Dim StartDate As Date
Dim TempFromDate As Date
Dim TempString As String ' holds the date of 1/1/ of this year
Dim TempYr as Double
StartDate = Format("01/15/2000") ' assign this as needed, or get from a database
TempFromDate = DateValue(StartDate)
TempYr = 100 + Val(Format(TempFromDate, "yyyy")) -
Val(Format(DateValue("01/01/2000"), "yyyy"))
REM The above seems to hard-code Y2K, but it works with any date, Y2K or less.
TempYr = TempYr * 1000 ' get it to the beginning of the number
TempString = "01/01/" + Format(TempFromDate, "yyyy")
fromdate = TempYr + TempFromDate - DateValue(TempString) + 1
Debug.Print fromdate '(Results = 100015)
End Sub
CONVERT JULIAN TO DATE
Sub ConvertJulToDate()
Dim JulDate As Long
Dim TempDate As String
Dim SQLDate As Date
JulDate = 101099 ' Assign as needed or get from JDE field
TempDate = "01/01/"
If JulDate > 99999 Then
TempDate = TempDate + Mid(LTrim(Str(JulDate)), 2, 2)
Else
TempDate = TempDate + Left(LTrim(Str(JulDate)), 2)
End If
SQLDate = DateAdd("d", Val(Right(Str(JulDate) - 1, 3)), TempDate)
Debug.Print SQLDate, Format(SQLDate, "mm/dd/yyyy")
' RESULTS: 04/09/01 04/09/2001
End Sub
JDE and JD Edwards are copyrights of JD Edwards Inc, All rights reserved. MiniSolve has
no affiltialation with JD Edwards, either stated or implied. JD Edwards does not know
anything about these programs, so please don't contact them.
Back to Mini Solve Products and other Tips
|