Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

basic time and duration calculations

Featured Replies

  • Newbies

Help! I am a bit baffled about how Filemaker handles calculations with time/duration variables. Does anyone have suggestions regarding the easiest way to these variables in caculations (or scripts)? In particular, I would like to find a way to calculate something like the following:

3:10 * 5

(that is 3 hours and 10 minutes, times 5) to yield 15:50

or

(EndDate - StartDate)*(EndTime-StartTime)

to get a total duration of some daily activity for the specified time

Does anyone have a custom calculation or script that does something like this? Or perhaps does FileMaker have some functions I haven't found yet? (The only thing I've figured out so far is converting everything into minutes, doing the calculation, and then using remainder calculations, etc. to re-assemble a time value. There must be a better way!

Time is seconds & date is days. A day = 24 Hours/day * 60 Minutes / Hour * 60 Seconds / Minute. You can choose to display the result as a number, a time or a date. The date may look a little strange.

  • Author
  • Newbies

Thank you, Ralph. I guess that should have been obvious to me. I'm still struggling, though, to get the results of a time calculation to display as a calculation. For example, I have function that calculates

2*(3:30 - 3:00) and comes up with 3600. I would like the 3600 seconds caluclated to appear as 1:00

(1 hour, zero minutes). The field (having the value 3600) is of type TIME. The format of the field on the layout is specified as "hh:mm". But it still shows up as "3600".

How do I make filemaker treat this calculated result like a time value, and show it to me in hh:mm form?

Hi dd3, and welcome to the Forum.

If you are not concerned about weekends, this will give you the elapsed time:

((End Date - Start Date) * 86400) + Time Out - Time In

and by hard coding it with the * 5, it will provide you with your desired result:

(((End Date - Start Date) * 86400) + Time Out - Time In) *5

If the "5" represents a number that needs to be changed from time to time, then use a field in its place. I have created a number filed called "No_of_Employees" for the purpose of demonstration:

(((End Date - Start Date) * 86400) + Time Out - Time In) * No_of_Employees

HTH

Lee

cool.gif

The fact that you are getting 2 * ( 3:30 - 3:00) to produce 3600 tells me the calculation is set to be a number. I just tried this in FMP7 and got 1:00.

  • Author
  • Newbies

Hmmm. Well the field is defined as a Time variable. And the field on the layout is formatted to display a Time value (hh:mm). The calculation itself actually mixes Date and Time fields in an IF statement. In oversimplified form: (Day2 - Day1) * (Time2 - Time1). So perhaps that makes the calculated value a "number" rather than a "time" in spite of the formatting.

OK, here's an approach that works, leveraging the knowledge that time is stored in seconds and the answer needs to be made into a time instead of a number -- just use the Time function.

Time(0,0,(Day2 - Day1) * (Time2 - Time1))

Whew, it works.

Thank you for all your thoughts and inspiration. I was getting ready to give up.

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.