julian date conversion

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
supernova2005
Participant
Posts: 37
Joined: Mon Jan 24, 2005 10:12 am

julian date conversion

Post by supernova2005 »

Hi everyone,

I need to convert a julian date with formate yyyyddd to regular date formate, for example,

if the input is 2005001, then the output is 01/01/2005. Does datastage have a built-in function to do that, otherwise I have to write my own logic, which is very complicated, because I have to consider leap years.

Your suggestions will be appreciated.

thanks.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

If you can be certain that your source data are correct you can write a simple expression, maybe encapsulating it for re-use in a Transform.

Code: Select all

Oconv(Iconv(JulianDate, "DYJ"), "D/MDY[2,2,4]")
(assuming you want month-day-year order. Adjust the second argument of Oconv for other formats.

If you are not certain that your source data are correct Julian dates then you would be better of with a routine that can check.

Code: Select all

FUNCTION JulianToMDY(JulianDate)
intDate = Iconv(JulianDate, "DYJ")
If Status() = 0
Then
   Ans = Oconv(intDate, "D/MDY[2,2,4]")
End
Else
   Ans = @NULL
   Call DSTransformError("Invalid Julian date (" : JulianDate : ")", "JulianToMDY")
End
RETURN(Ans)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply