convert time duration in decimal.

Hello Everyone,

please help me to get value on period start and period end time.

i have to get value like below format.



00:00-12:59 as 00



03:00-03:59 as 03



19:00-19:59 as 19



for 24 hour time period.







Thanks in advance.

Hi Shyam,

Can you be specific , i understood like you just need starting hour/ period which can be taken like

if your Time Format is HH-MM-SS then

TimeInText := FORMAT(Time);

then you just need Hours.

EVALUATE(Hourtime,COPYSTR(TimeInText,1,2));

OR IF you are getting like HH-MM-SS-AM.

then

Same above

IF COPYSTR(TimeInText,10,2) = ‘PM’ THEN
Hourtime += 12;//to add to your previous time as it pm eg: 6 + 12 = 18 pm

So make some additional conditions so that you achieve your Requirements ,

Let me know if helped[:D]

Dear Sir,

Thank you for the help,

Logic provided by you is working fine for me.we are copying first 2 values from time field.

But in the case of 12:00:00-12:59:59 Am i want to display 00 in place of 12.

For PM time period its perfect. so any suggestion for that?

Kindly check the below output.

12:00:00 AM-12:59:59 AM 12 >> Instead 00 Required

1:00:00 AM- 1:59:59 AM 1

3:00:00 AM- 3:59:59 AM 3

4:00:00 AM- 4:59:59 AM 4

11:00:00 AM-11:59:59 AM 11

12:00:00 PM-12:59:59 PM 12

1:00:00 PM- 1:59:59 PM 1

2:00:00 PM- 2:59:59 PM 2

5:00:00 PM- 5:59:59 PM 5

6:00:00 PM- 6:59:59 PM 6

7:00:00 PM- 7:59:59 PM 7

8:00:00 PM- 8:59:59 PM 8

9:00:00 PM- 9:59:59 PM 9

10:00:00 PM-10:59:59 PM 10

11:00:00 PM-11:59:59 PM 11

Thanks again for the help.

Hi Shyam,

I got it as 12PM is 12T , So you need 12 Am i.e 00T .So i think you definitely use/ compare for AM or PM from Above post of mine… i.e copy AM/Pm , Then why dont you compare it before taking further step as like

IF (Hourtime = 12) AND (AM_PM = 'AM) Then

Hourtime := 00T;

If it is NOT Helpful then Let me Know…[;)]

right sir…But when i am trying to assign 12 in Hourtime getting type conversion error.

can you tell me Hourtime datatype or i have to take another variable of time type.

Hi Shyam ,

Go Through This post below …[:D]

http://beginnersnav.blogspot.in/2015/12/convert-time-to-decimal-interger-as-per.html

Let me Know if you got your requirement…[;)]

Thanks sir

it works for me.