Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

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

Learn more

View all

Sign in to view all badges

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list

formula for Time going past midnight in Designer


Not applicable

I am having somewhat of a hard time finding a good formula to use in Livecycle Designer for working out hours that go past midnight.

I have a timesheet which is great for anyone working during daytime hours but if i want to use it for someone who does nightwork it keeps returning a negative value.

I have two datetime fields for start(FldStart) and finish(FldEnd).

Problem occurs when i have 22:30 for start and 02:30 for end.

I already have a calc to convert them to decimal in the Hours worked field so i'm in a bind here???????????

My time format is HH:MM.

4 Replies


Not applicable
Sorry forgot to add the code that i have in FldHrsWorked.

FldHrsWorked.rawValue = ((Time2Num(FldEnd.formattedValue, "HH:MM") - Time2Num(FldStart.formattedValue, "HH:MM")) / (60 * 60 * 1000)) - FldLessBreaks

I desperately need to add something in this to work out the hour once it passes midnight.



Level 7
You will have to include the date for the start and end time in the calculation.


Not applicable
Hi Geo,

Firstly thankyou for your reply.

I am new to this and i am self taught when it comes to things IT so please excuse me if i get a little confused. When you mention that i have to include the date for start and end time do you mean i have to have the code something like this:

FldHrsWorked.rawValue = ((Time2Num(FldEnd.formattedValue, "date{DD-MM-YY} time{HH:MM}") - Time2Num(FldStart.formattedValue, "date{DD-MM-YY} time{HH:MM}")) / (60 * 60 * 1000)) - FldLessBreaks

I have put that code in to see if it worked but alas, nothing happens in my FldHrsWorked field now.

I was reading in excel that if you put the formula =A2+(A1>A2)-A1 it will Subtract Times That Span Past Midnight Into a New Day but i can't figure how to add that in my original code.

I really don't want to have the guys put in date and time for both fields as, well, put simply the whinging from them will do my head in!!!!!!

Yours or others response would be a great help for me.

PS: I think the Time2Num might be the cause here with the new code that i tried.


Not applicable
Thanks Geo, but i finally figured it using numerous fields and calcs.