OConv functionality

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
Ush
Participant
Posts: 55
Joined: Tue Dec 04, 2007 3:15 am

OConv functionality

Post by Ush »

Hi

I have a requirement as below:
I give input to my as seconds
datetimefromunixtime ( integer(8) seconds )
-It should return a datetime from a count of seconds since 1970 (UNIX time).

My code:
temp=0
flag=0
if ((TimeInSec>=-4 AND TimeInSec<0) )
then
Ans = " 01 JAN 1970 12:00:00am"
end

if (flag =0 AND TimeInSec>=0)
then
Noofdays=TimeInSec/86400 + 732
RemainingTime=(MOD(TimeInSec,86400))
F1=oconv(Noofdays,"D")
F2=oconv(RemainingTime,"MTHS")
Ans=" " : F1 :" " : F2
end
else
if (flag =0 AND TimeInSec<-4)
then
z: temp = temp+1
TimeInSec = TimeInSec+86400
if(TimeInSec<0) then goto z

Noofdays=TimeInSec/86400 + 732

Noofdays = Noofdays - temp
RemainingTime=(MOD(TimeInSec,86400))
F1=oconv(Noofdays,"D")
if (RemainingTime < 86400 AND RemainingTime > 86395 ) then F2 = "12:00:00am" else F2=oconv(RemainingTime,"MTHS")
Ans=" " : F1 :" " : F2
end
end

These are the test cases for the code.

The code is not giving proper output for
86396 to 86399. Rest all problematic cases are manipulated to near actual result. OCONV function does not work for inputs (-1 to-4) & 86396 to 863999).

please let me know about the same.
Thanks
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Look in the SDK for routines that deal with 1970-based dates.
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