Page 1 of 1
Convert Julian Date to DB2 Date
Posted: Wed Dec 01, 2004 1:50 pm
by anilkona
I am trying to convert a julian date to DB2 date format using the following syntax:
Oconv(Iconv(MyDate, "DYJ"), "D-YMD[4,2,2]")
I am getting following error when I do that
Value treated as NULL
Attempt to convert String value "" to Date type unsuccessful
The Julian dates are in the form of 99111, 100018 etc.
Can anyone suggest a correct syntax.
Thanks,
-Anil
Posted: Wed Dec 01, 2004 2:02 pm
by kcbland
Please search this forum, we just last week had a long discussion over Y2K issues with Julian dates and the DB2 plugin. Your solution is discussed in that thread.
Posted: Wed Dec 01, 2004 3:39 pm
by anilkona
I looked at that post. And I tried the following syntax:
Oconv(Iconv(1900 + Int(JulianDate / 1000) : "/" : Mod(JulianDate, 1000), "DYJ"), "D-YMD[4,2,2]")
I still get the same error.
What I noticed was IConv function is not returning any value.
Anyone has a working solution?
Thanks,
-Anil
Posted: Wed Dec 01, 2004 3:41 pm
by T42
JulianDate is the variable you need to pass.
Use MyDate there.
Posted: Wed Dec 01, 2004 3:44 pm
by anilkona
Yes I did. This is what I tried:
Oconv(Iconv(1900 + Int(104071 / 1000) : "/" : Mod(104071, 1000), "DYJ"), "D-YMD[4,2,2]")
Thanks,
-Anil
Posted: Wed Dec 01, 2004 4:56 pm
by anilkona
I think I found a solution. Put this in a function
Ans = @NULL
If IsNull(Arg1) Then RETURN(Ans)
TheYear = Arg1[1,Len(Arg1)-3] + 1900
TheDay = Arg1[3] ;
DSJulianDate = TheYear : "" : TheDay
Ans = Oconv(Iconv(DSJulianDate, "DYJ"), "D-YMD[4,2,2]")
RETURN(Ans)