difference between two timestamp fields

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
kausmone
Participant
Posts: 39
Joined: Fri Sep 21, 2007 1:47 am
Location: Prague

difference between two timestamp fields

Post by kausmone »

Hello again,

I have to compare a timestamp value (lets call it T1) available in a hashed-file with current timestamp (T2). If (T2 - T1) > 4 hours, then write the record to output file.

Is there any function available that will convert timestamps to internal storage format? If I am to use Iconv, I will need to separate the date and time parts, convert them individually to their internal values and compare these. But this will call for some tedious and not-really-readable code. Also, making it bug-free will not be easy...

Is there some way to calculate the epoch, like convert T1 to total number of seconds from 1970, do the same for T2 and compare with 4*60*60 seconds?

Thanks in anticipation!

Rgds,
Kaus
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Timestamps (in ISO 8601 format YYYY-MM-DD HH:MM:SS) can be compared directly as strings - you don't need any functions at all.
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