Page 1 of 1

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

Posted: Tue Mar 11, 2008 8:12 pm
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

Posted: Tue Mar 11, 2008 8:32 pm
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:")

Posted: Thu Mar 13, 2008 4:02 am
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]')