how to "YYYY-MM-DD HH:MM:SS" add ########## second

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
zealcrash
Participant
Posts: 6
Joined: Sun Feb 25, 2007 8:14 pm

how to "YYYY-MM-DD HH:MM:SS" add ########## second

Post by zealcrash »

(my English writing level is low...sorry T_T)

Hi

I had a job like this

===========================
= Sequencefile => Transformer => DB2 =
===========================

one column of source sequence file is '1435668237'

this is seconds :(

I wanna insert data to target DB2 like this format

'YYYYMMDD'

a method of cacaluation is '1970-1-01 09:00:00' add '1435668237 seconds'

result => YYYYMMDD

I had a solution by SQL query....

but I wanna know a way by DS Function or Routine :)

Plz give me lessons :roll:

thanks for reading my topic :o
Last edited by zealcrash on Wed Mar 12, 2008 12:54 am, edited 2 times in total.
ZealCrash
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

In server edition dates are stored as days since 1967-12-31, and times as seconds since midnight. You need to tear apart your timestamp into date and time portions, and convert your increment into days and seconds.

Code: Select all

svStartDay = Iconv(Field(InLink.TheTimestamp, " ", 1, 1),"DYMD")
svStartTime = Iconv(Field(InLink.TheTimestamp, " ", 2, 1), "MTS")

svIncrDays = Int(InLink.Seconds / 3600)
svIncrSecs = Mod(InLink.Seconds, 3600)

svResultDays = svStartDay + svIncrDays
svResultSecs = svStartTime + svIncrSecs

svNewDays = (If svResultSecs >= 86400 Then svResultDays - 1 Else svResultDays)
svNewSecs = (If ResultSecs >= 86400 Then svResultSecs - 86400 Else svResultSecs)

svNewTimestamp = Oconv(svNewDays, "D-YMD[4,2,2]") : " " : Oconv(svNewSecs, "MTS:")
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
santhooosh.c
Participant
Posts: 6
Joined: Tue Jan 29, 2008 3:48 am
Location: Chennai

Post by santhooosh.c »

This one should be helping you

Input 1: '1435668237'
Input 2: '1970-01-01 09:00:00'

Oconv(Iconv(Input2(1,10),'D-YMD[4,2,2]') + MeasureTimeSecondsToDays(Input1)),'D/YMD[4,2,2]')
Santhosh
Post Reply