Solved

field calculation that rounds up to a "nearest value"

Posted on 2008-06-19
3
825 Views
Last Modified: 2010-04-21
In our invoice/billing system, our technicians clock in and out of each work ticket. We have a field that calculates the "time billed" based on these time ins and outs (there can be up to three ins and outs on each ticket).

Currently our method is as listed in the code snippet. This field calculates to the minute, so if we clock in at 10:00 and clock out at 10:08 it calculates 8 minutes. A change in our pricing structure has been made so that there is a minimum of 15 minutes for service calls (and time is billed in 15 minute increments).

We would like to change this field so that for each time in/out instance, it rounds UP to the nearest 15 minute increment (IE 15, 30, 45, 60, etc..). It would round for each time in/out instance, then add those (up to) three values for the "total time".

Also, should we create a new field for this? We don't want to recalculate any of the existing data as that would change values on outstanding invoices. Currently it is set in storage options to "recalculate as needed".

Thanks!
(BILLING_ITEMS::TIME_OUT_1 - BILLING_ITEMS::TIME_IN_1) + (BILLING_ITEMS::TIME_OUT_2 - BILLING_ITEMS::TIME_IN_2) + (BILLING_ITEMS::TIME_OUT_3 - BILLING_ITEMS::TIME_IN_3)

Open in new window

0
Comment
Question by:Eroots
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 19

Accepted Solution

by:
billmercer earned 250 total points
ID: 21825866
Here's a simple formula that will "round up" to the next 15.

 Ceiling( NumberOfMinutes / 15) * 15

If you enter any number of minutes from 1 to 15, it returns 15. If you enter 16, it returns 30, and so forth.

With regard to your history, you definitely don't want to change historical data, so creating a new field for this purpose might be a good idea, but it might also complicate things if you have lots of references to the old field.

One way you could handle that would be to make your calculation conditional on the invoice date. Apply the old calculation for records created before a specific cut-off date, and the new one for any created after that date.


If ( InvoiceDate  >=  "5/1/2008" ;
   Ceiling( NumberOfMinutes / 15) * 15;
   NumberOfMinutes
)

This formula applies the rounding up function to any records with a date of 5/1/08 or later, and simply returns the original number for earlier dates.
0
 

Author Closing Comment

by:Eroots
ID: 31468799
Thanks for introducing the ceiling function, but it took me a while to figure out the whole calculation as it applies to minutes. Here is what I came up with:

(Ceiling ((( Hour ( BILLABLE_TIME )*60)+Minute ( BILLABLE_TIME )) / 15 ) * 15) * 60
0
 
LVL 19

Expert Comment

by:billmercer
ID: 21846193
Hmm, you didn't mention anything about needing to calculate the time difference in your original question, and said you'd already done that before, so I assumed you already knew how.

The formula you used works, but there's a simpler way.

FileMaker times are stored as numbers of seconds internally. They are displayed with formatting to show hours, minutes, etc, but internally it's just a number of seconds.

That means you can do normal math with time values. If you subtract Time A from Time B, you get the difference between the two times in seconds.

Assuming BILLABLE_TIME = END_TIME - START_TIME then all you need to do is

  Ceiling(  BILLABLE_TIME / 60 / 15 ) * 15


0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Pop up windows can be a useful feature of any Filemaker database.  Though best used sparingly, they can be employed in a multitude of different ways, for example;  as a splash screen at login, during scripted processes to control user input, as pick…
Problem: You have a hosted FileMaker database and users are tired of having to use Open Remote or Open Recent to access the database. They say, "can't you just give us something to double-click on rather than have to go through those dialogs?" An…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question