Unix TimeStamp Convert

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

ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

mkeevil,

the code I posted is a 1-liner that you can put right into your derivation in a TRANSform stage. Is that sufficient?
mkeevil
Participant
Posts: 59
Joined: Mon Jul 14, 2003 12:59 pm
Location: USA

Post by mkeevil »

Ok so I created the function and a test batch.... I was just told though that the input date will be differnt, it will be '19-04-2005 00:00:00' so I would have to change the function to be
Ans = (iconv(datepiece,"D-DMY[,A3,]") - iconv("1 jan 1970","D"))


DEFFUN UnixTime(DateIn) Calling "DSU.UnixTime"

DateIn = '19-04-2005 00:00:00'
Result = UnixTime(DateIn)

Call DSLogInfo("Input Date: ":DateIn,"Batch::UnixConvertTest")
Call DSLogInfo("Converted: ":Result,"Batch::UnixConvertTest")
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

The iconv must be of format 'D-DMY[2,2,4]'.
mkeevil
Participant
Posts: 59
Joined: Mon Jul 14, 2003 12:59 pm
Location: USA

Post by mkeevil »

It worked correctly with both formats... Thanks for your help everyone.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Aren't there already SDK functions to 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