Level 1

0% to

Level 2

Tip /

to gain points, level up, and earn exciting badges like the new
Mission!

View all

## FormCalc time calculation 24 hour format

Sunaj76
Level 1

Like

1 like

Total Posts

2 posts

0 solutions
View profile

Sunaj76
Level 1

Like

1 like

Total Posts

2 posts

0 solutions
View profile
Sunaj76
Level 1

30-01-2018

Need help with a FormCalc script for time diffrence in 24 hour format on same day.

My table have repeted rows. User enter date, start time, end time and break time for each row

If he starts work midnight he enter 00:00 and if ending midnight he enter 00:00 (display set to "KK:MM" therefore 00:00 = 24:00)

All work great when entering 00:00 to 23:59

But when entering 00:00 (24:00) in end time the diffrence is -24 hours

What line do I need to add so it will work with 00:00 in the WorkTo?

form1.#subform[0].Table1.Row1.WorkTotalWorkTotal::calculate - (FormCalc, client)

var startTime = Time2Num(WorkFrom.formattedValue, "HH:MM")

var finishTime = Time2Num(WorkTo.formattedValue, "KK:MM")

if (WorkFrom==null | WorkFrom=="" |  WorkTo==null | WorkTo=="")

then \$=""

else

\$=((finishTime) - (startTime)) / 3600000 - WorkBreak

endif

#### Accepted Solutions (0)

MVP

Likes

397 likes

Total Posts

2,687 posts

492 solutions
View profile

MVP

Likes

397 likes

Total Posts

2,687 posts

492 solutions
View profile
MVP

31-01-2018

Since 00:00 and 24:00 are the same, you'll have to add another if expression:

`if (not WorkFrom.isNull and not WorkTo.isNull) thenvar startTime = Time2Num(WorkFrom.formattedValue, "HH:MM")var finishTime = Time2Num(WorkTo.formattedValue, "KK:MM")if (startTime eq finishTime) then\$ = 24else\$ = (finishTime - startTime) / 3600000endifelse\$ = ""endif`

Sunaj76
Level 1

Like

1 like

Total Posts

2 posts

0 solutions
View profile

Sunaj76
Level 1

Like

1 like

Total Posts

2 posts

0 solutions
View profile
Sunaj76
Level 1

31-01-2018