convert 12hrs as a 24hrs

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
harikumar
Participant
Posts: 33
Joined: Wed Apr 21, 2010 9:19 pm
Location: banglore

convert 12hrs as a 24hrs

Post by harikumar »

i have source like
balance,drawtime
20000, 8.30
50000,10.20
3000,4.00

i want target like this
balance,drawtime
20000, 20.30
50000,22.20
3000,16.00
Last edited by harikumar on Mon Jun 28, 2010 11:22 pm, edited 1 time in total.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

There's no such thing as "20.30am" or "16.00pm", it's either 12 hour notation with AM/PM or 24 hour notation without it. Use StringToTimestamp() and then TimestampToString() with the appropriate Time Format string for each step, one to read it into internal format as 12hour and the other to write it back out to an external format using 24hour.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

What's the data type of drawtime? Assuming it's a string, you can use Field() functions, arithmetic (add 12) and concatenation to build the desired output string.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
antonyraj.deva
Premium Member
Premium Member
Posts: 138
Joined: Wed Jul 16, 2008 9:51 pm
Location: Kolkata

Post by antonyraj.deva »

harikumar wrote:i have source like
balance,drawtime
20000, 8.30
50000,10.20
3000,4.00
In this data, how do you differentiate between AM & PM?

Without that information the conversion would not be possible.
TONY
ETL Manager
Infotrellis India

"Do what you can, with what you have, from where you are and to the best of your abilities."
venugopal.123
Participant
Posts: 9
Joined: Sun Jun 27, 2010 11:52 pm

Post by venugopal.123 »

It is simple Tony drawtime between 00.01 to 11.59 is AM and 12.00 to 24.00 is PM
antonyraj.deva
Premium Member
Premium Member
Posts: 138
Joined: Wed Jul 16, 2008 9:51 pm
Location: Kolkata

Post by antonyraj.deva »

venugopal.123 wrote:It is simple Tony drawtime between 00.01 to 11.59 is AM and 12.00 to 24.00 is PM
Not that simple I guess Venugopal. In 12 hour format without the AM/PM mentioned as it is the case with the source data example provided by Harikumar, 4:00 can be either morning or evening.

And one more thing is that 12:00 to 23:59 is not available in 12 hour format. :)
TONY
ETL Manager
Infotrellis India

"Do what you can, with what you have, from where you are and to the best of your abilities."
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

The original question has been edited from what was posted last night. All examples had an "am" or "pm" at the end, source and target, hence my comment which was speicific to the target 'needed'. The poster then over-reacted and removed too much in (what I assume was) an attempt to correct things. Now, as noted, the examples as posted are still invalid, just in a different manner. :evil:

Still doesn't change my answer.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply