Jump to content

Help with a Time Calculation please


This topic is 8348 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hi, Could someone assist me with this problem in FM 5: I have a starttime field and an endtime field. I do not know how to format them as time fields. I wish to use a calculated field to return the difference in decimal, to one decimal place. The formula needs to account for times either side of midnight. I would prefer not to have to enter accompanying dates as this circumstance occurs often enough to warrant allowing for it, but not often enough to justify two date fields.

I have tried Timecalc=If(endtime<starttime,endtime+24,endtime)-starttime. The value returned does not make sense.

Thanks for any assistance offered.

Link to comment
Share on other sites

Give this a try. Times must be entered as 24 hours times using "16:30" type notation.

DeltaTime (calculation, number) =

Round(

Int(Case(EndTime * StartTime, EndTime - StartTime, EndTime - StartTime + Time(24, 0, 0)) / 3600)

+

Minute(Case(EndTime * StartTime, EndTime - StartTime, EndTime - StartTime + Time(24, 0, 0))) / 60

+

Seconds(Case(EndTime * StartTime, EndTime - StartTime, EndTime - StartTime + Time(24, 0, 0))) / 3600

,1)

-bd

[ July 08, 2001: Message edited by: LiveOak ]

Link to comment
Share on other sites

Thanks for the help. Maybe cause its 0100 or maybe cause I am not upto speed, could you please clear up some dumb questions for me. One, how do ensure that time values hh:mm are being entered into the fields used for calculation? Two, what do I do with the formula text that you have provided if I want the result to be diplayed by a calculated field?

Thanks for the patience.

Link to comment
Share on other sites

1) Set the field validation for the time fields to be "Strict" of type "Time" and 2) Use the forumula text as the definition for the calculation field. In my example you will define the following fields:

StartTime (time, strict time validation, can't override)

EndTime (time, strict time validation, can't override)

DetlaTime (calculation, number) = [use the formula I gave you]

The forumula text IS the definition of the calculation field. You can copy and paste the formula after the "=" into the field definition, if you define the two entry fields as above.

-bd

Link to comment
Share on other sites

This topic is 8348 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.