Timestamp comparison

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
rsunny
Participant
Posts: 223
Joined: Sat Jul 03, 2010 10:22 pm

Timestamp comparison

Post by rsunny »

Hi,

I have a requirement where i need to compare the time stamp from source and Reference records and if the time stamp from the source is greater than Reference record, i need to pass the data.i am getting the time stamp from source and reference as '2011-07-21 03:24:46.000000 AM'.

When i gave the condition as Source time stamp>Reference Time Stamp, the condidtion is not satisfying and i am passing the records which i should not.Can anyone please help me in this issue .I tried to convert the Time stamp to Internal format by using Iconv but still not satisfying .

Thanks in Advance
Ravi.K
Participant
Posts: 209
Joined: Sat Nov 20, 2010 11:33 pm
Location: Bangalore

Post by Ravi.K »

Use Iconv function for both Source and Reference data then compare both values.
Cheers
Ravi K
rsunny
Participant
Posts: 223
Joined: Sat Jul 03, 2010 10:22 pm

Post by rsunny »

Ravi.K wrote:Use Iconv function for both Source and Reference data then compare both values.
I have used Iconv function but still not able to satisfy the condition.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

If you have any control over the format of the timestamp from the source, make sure it is in military time. Strings just like you posted in 24 hour time will compare just fine.
Last edited by chulett on Fri Sep 02, 2011 2:47 pm, edited 1 time in total.
-craig

"You can never have too many knives" -- Logan Nine Fingers
rsunny
Participant
Posts: 223
Joined: Sat Jul 03, 2010 10:22 pm

Post by rsunny »

Hi,

Basically what i did is i tried to convert the time stamp to 24hr format like '2011-02-21 15:24:46' and then used Iconv('2011-02-21','D-YMD[4,2,2]'):Iconv('15:24:46':'MTS') for comparison

Please let me know if i am doing anything wrong.

Thanks in advance
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Show us every step... and you don't need to convert things twice. Heck, if you were successful in converting to 24 hour strings then (as I said) you can compare them directly.
Last edited by chulett on Fri Sep 02, 2011 2:49 pm, edited 1 time in total.
-craig

"You can never have too many knives" -- Logan Nine Fingers
sandeepgs
Participant
Posts: 87
Joined: Wed Jul 02, 2008 12:22 am

Post by sandeepgs »

Hi,

I have seen this kind of issue the apt solution is as follows.

Read the time value as string and convert the AM/PM by adding +12 to the existing value i.e you are converting the time to a 24 hour time frame

Note: The condition can only applied in stage variables using transformer.

And then do the necessary calculations.

There are so many posts available in DSXchange on converting AM/PM format to 24 Hour format. go through them for more detail explination of business logic.

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

Post by ray.wurlod »

ISO 8601 prescribes the format of a timestamp.

If your timestamps conform to this format, then you don't need to to anything other than compare them with a ">" operator.
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