Page 1 of 1

convert 12hrs as a 24hrs

Posted: Mon Jun 28, 2010 10:02 pm
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

Posted: Mon Jun 28, 2010 10:18 pm
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.

Posted: Tue Jun 29, 2010 1:14 am
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.

Posted: Tue Jun 29, 2010 3:14 am
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.

Posted: Tue Jun 29, 2010 3:36 am
by venugopal.123
It is simple Tony drawtime between 00.01 to 11.59 is AM and 12.00 to 24.00 is PM

Posted: Tue Jun 29, 2010 3:44 am
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. :)

Posted: Tue Jun 29, 2010 6:51 am
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.