Convert Julian Date to DB2 Date

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
anilkona
Participant
Posts: 50
Joined: Mon Nov 15, 2004 6:18 pm

Convert Julian Date to DB2 Date

Post 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
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post 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.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
anilkona
Participant
Posts: 50
Joined: Mon Nov 15, 2004 6:18 pm

Post 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
T42
Participant
Posts: 499
Joined: Thu Nov 11, 2004 6:45 pm

Post by T42 »

JulianDate is the variable you need to pass.

Use MyDate there.
anilkona
Participant
Posts: 50
Joined: Mon Nov 15, 2004 6:18 pm

Post 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
anilkona
Participant
Posts: 50
Joined: Mon Nov 15, 2004 6:18 pm

Post 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)
Post Reply