Solved

field calculation that rounds up to a "nearest value"

Posted on 2008-06-19
3
819 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
  • 2
3 Comments
 
LVL 19

Accepted Solution

by:
billmercer earned 250 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

762 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now