Calculating with timestamps in a sequence job

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
ke.rstin_
Participant
Posts: 25
Joined: Mon Apr 16, 2012 1:08 pm

Calculating with timestamps in a sequence job

Post by ke.rstin_ »

Hi datastagers,
in order to calculate the period of time between a fix timestamp and the current timestamp I would need something like a SecondsSinceFromTimestamp(fix_timestamp, current_timestamp) in my sequence job but unfortunately haven't found a good possibility to do that so far. Do you have any ideas?

Best regards,
ke.rstin_
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You'd need to create a custom routine and then run that in the Sequence job and that means writing it in BASIC. I think you'll find Ray has some prebuilt that he gives away on his site that do "date math"... let's see what he says when he wanders by. :wink:

Once you have computed this period of time (in seconds?) then what do you need to do with it?
-craig

"You can never have too many knives" -- Logan Nine Fingers
ke.rstin_
Participant
Posts: 25
Joined: Mon Apr 16, 2012 1:08 pm

Post by ke.rstin_ »

Hi Chulett,
what I need it for: I have a loop where I start a wait-for-file-job to see if the file is already here. Let's say they are named File1 ... File32. In my wait-for-file-job I compare the current date with the start date of the main sequence in order to guarantee that the whole searching process doesn't need longer than two hours. If I set my timeout for every file separately I could get in trouble because it runs too long. :roll:
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The routines that Craig mentioned are here - however there isn't a TimestampDifference in that set.

This can be done with a simple expression (it only looks complex). That expression can be used in a sequence or in server job components or even in a BASIC Transformer stage.

Code: Select all

(Iconv(Field(Timestamp2, " ", 1, 1), "DYMD") * 86400 + Iconv(Field(Timestamp2, " ", 2, 1), "MTS")) - (Iconv(Field(Timestamp1, " ", 1, 1), "DYMD") * 86400 + Iconv(Field(Timestamp1, " ", 2, 1), "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.
ke.rstin_
Participant
Posts: 25
Joined: Mon Apr 16, 2012 1:08 pm

Post by ke.rstin_ »

Hi Chulett and Ray,
thank you for your help.
Unfortunately I can't see Ray's full entry because I'm no premium member (I know that's my own fault ;)). We made a workaround which doesn't really do exactly what it should, but it's enough for the job:

We have a load_timestamp for the start of the main sequence and we create a current date with a user variable activity. It's compared via a nested condition.

Best regards, ke.rstin_
Post Reply