You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

In OS Numbers: Indicating if now is between two times with IF or something better.

I have 5 flights listed using two departure airports with Dep and Arr times in a spreadsheet with the times calculated at which I would have to start getting ready to make each of those flights.


Based on a callout time or the current time "now" function, I would like to turn the "get ready" time green for the next flight I could make based on that callout time.


Basically, if the current time is between 12:00 and 14:00, the next flight I could make turns green.

If the time is after 14:00 but before 16:15, this flight is the one I should start getting ready for.


To make it simple, I would be happy just doing an IF statement next to each flight that says if "NOW" is between 12:00 and 14:00, put an "X" here next to the next flight I could get ready for and make. Maybe turning the "get ready" time green is too complicated.


Many thanks.


MacBook Air 13″, macOS 14.5

Posted on Aug 1, 2024 2:27 PM

Reply
2 replies

Aug 1, 2024 3:03 PM in response to D328jet

Sorta, kinda :)


Depends on how much work you want to do :)


First and foremost, understand that the NOW() function only updates when the sheet is edited in some way - it isn't possible (at least without external support) to have a continuous timer running on a sheet.


That said, the second step would be to use Conditional Formatting, which you can use to automatically change the formatting (e.g. color) of a cell based on its contents.


In this way you could create a cell with the Conditional Highlighting to change the color to green if the cell value is higher than a cell containing the =NOW() formula.


E.g. if cell $B$2 contains the formula "=NOW()" then you can:



So now the cell will turn green if the date in the cell is in the future.


However, Conditional Highlighting only takes one dimension - in other words, all future flights will turn green, not just the next one (to do that you have to compare it to not only NOW(), but also the other departure times in the list.


It's also a little more complicated by the fact that, internally, Numbers uses full dates, even if it only displays a time.

For this I mean that if you type "3:00pm" into a date cell, Numbers would internally reference that as "1/8/2024 3:00pm" which would be a problem tomorrow when NOW() returns '2/8/2024 3:00:00pm" and all your departure times are in the past.

You can get around this by stripping the date component and just storing a time value - in other words, instead of entering '3:55pm' in the field (which Numbers would assume meant 3:55pm today), you would enter "=TIME(15,55,0)' so that it only captured the time, regardless of the date.


You'd have to do something similar with your =NOW() function to strip out the date component.


The function:


=TIME(HOUR(NOW()), MINUTE(NOW()),0)


would give you the current HH:MM time in a cell, regardless of the date.


To take this to the next level (e.g. to only highlight the next viable flight) you'd need to either do some fancy lookups (offhand I can think of creating a separate table of times and using LOOKUPs to find the next), or use AppleScript to drive Numbers under the hood. Both of which are big steps up.

Aug 1, 2024 3:53 PM in response to Camelot

This is great and I understood this very clearly but, I did the conditional rules and they didn't turn any of the times green. I stripped all the fields of dates so no matter what date NOW was, since this doesn't matter, it just gives a time, which is perfect because this is not date dependent. I will use this every day for example. I suppose, since there's no date, it can't determine whether the time is before or after since there's not a constraint of something like, all times without dates only exist within a 24 hr period starting from 00:00 and ending at 23:59. This is a problem. the flight schedule is not date dependent. Maybe turning the fields green needs to be based on the NOW time (and date) to determine "greater".


Second, I really need an IF statement that says something like, if B2 contains "NOW" (stripped of date), and it is between 12:00 and 14:00, then this field will exhibit the time calculation (NOW (stripped of date) plus a duration). Otherwise, it will be blank. I know how to do the calculation using DURATION.


Something like: IF(TIME(12,0,0)<B2<TIME(14,0,0),B2+C2,"")

B2=NOW

C2=DURATION or 14h

So basically I'm saying, if NOW is between 12:00 and 14:00 (irrelevant of the date), then calculate NOW plus 14hours. If it's not, leave the cell blank. If this cell ends up with a value, it should be red but I think I can do that easily.


I used your equation: =TIME(HOUR(NOW()), MINUTE(NOW()),0) for NOW so I'm not sure where it is getting a date from. This and the DURATION are the only two values in the equation.


I get this error: You can’t compare a Boolean with a date because their data types are different

In OS Numbers: Indicating if now is between two times with IF or something better.

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