need help with Numbers formula.

I have a formula that, in Excel, returns a number of minutes rounded up to the nearest 6 minutes then converted to tenths. In other words... a flight duration from 10:00 to 11:31 is 1.6hrs. Where as a flight duration from 10:00 to 11:29 is 1.5. I need to get the same result in a numbers formula that can work on an IPAD.


Here is the formula that works for Excel: =FLOOR((D18-C18)*1440,6)/60+0.1*(MOD(D18-C18,1)<>0)


D18 is the ending time in hours and minutes and C18 is the start time in hours and minutes.


The accepted and Govt approved conversion is as follows.

Minutes Time

1-6 .1

7-12 .2

13-18 .3

19-24 .4

25-30 .5

31-36 .6

37-42 .7

43-48 .8

49-54 .9

55-60 1.0


iPad Pro 9.7-inch WiFi, Cellular

Posted on Oct 11, 2020 1:41 PM

Reply
Question marked as Top-ranking reply

Posted on Oct 11, 2020 2:45 PM

The answer depends. A one-to-one equivalent would be


=FLOOR((TIMEVALUE(D18)−TIMEVALUE(C18))*1440,6)/60+IF(MOD((TIMEVALUE(D18)−TIMEVALUE(C18)),1)<>0,0.1,0)


In Excel, "times" have no dates. D18-C18 will give the difference between the two times as the decimal fraction of a 24 hr day. In Numbers, "date&time" cells include the date. The TIMEVALUE function converts them to a decimal fraction of a day, which effectively removes the date, then subtracts them.


The function given above fails if the end time is not in the same day as the start time (such as 11:59PM today to 1:00AM tomorrow). The Excel function fails, too.


If you want the date to be taken into consideration, this would be the formula:

=FLOOR(DUR2DAYS(D18−C18)*1440,6)/60+IF(MOD(DUR2DAYS(D18−C18),1)<>0,0.1,0)


You must ensure you also include the date when entering the times. The default is "today" if you enter time only. I would recommend you format the cell to show the date as well as the time.

If you format columns C and D as text, you can enter the "time" without a date. It will be text but Numbers will figure it out. Either formula will work. It will have the same problem regarding times that cross a date boundary.


12 replies
Question marked as Top-ranking reply

Oct 11, 2020 2:45 PM in response to Scott_Tripp

The answer depends. A one-to-one equivalent would be


=FLOOR((TIMEVALUE(D18)−TIMEVALUE(C18))*1440,6)/60+IF(MOD((TIMEVALUE(D18)−TIMEVALUE(C18)),1)<>0,0.1,0)


In Excel, "times" have no dates. D18-C18 will give the difference between the two times as the decimal fraction of a 24 hr day. In Numbers, "date&time" cells include the date. The TIMEVALUE function converts them to a decimal fraction of a day, which effectively removes the date, then subtracts them.


The function given above fails if the end time is not in the same day as the start time (such as 11:59PM today to 1:00AM tomorrow). The Excel function fails, too.


If you want the date to be taken into consideration, this would be the formula:

=FLOOR(DUR2DAYS(D18−C18)*1440,6)/60+IF(MOD(DUR2DAYS(D18−C18),1)<>0,0.1,0)


You must ensure you also include the date when entering the times. The default is "today" if you enter time only. I would recommend you format the cell to show the date as well as the time.

If you format columns C and D as text, you can enter the "time" without a date. It will be text but Numbers will figure it out. Either formula will work. It will have the same problem regarding times that cross a date boundary.


Oct 11, 2020 9:47 PM in response to Scott_Tripp

As an alternative to Badunit's excellent solution, you could also use:




=CEILING(DUR2HOURS(MOD(D2−C2,"12h")),0.1)


Possible advantages:


-- It will give you a meaningful result if occasionally you fly past midnight into another day (though not if the duration of the flight exceeds 24 hours).


-- It uses the vaguely aeronautical CEILING function.😀


The formula doesn't care if your cells in C and D are formatted as Date & Time or Text. Date & Time may be easier for data input on the iPad. I use Text on the Mac so I don't have to worry about entering the date in the same cell.


SG


This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

need help with Numbers formula.

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.