How can I prevent a Time formatted cell from also having a date in it?

I am tracking my child's sleep schedule and I have a column for the Date which is formatted to Date & Time and set to have "None" for Time and that column is working as expected (it just includes the date). The next two columns are for Sleep Start and Time Awake. I have both of those columns formatted to Date & Time and set to have "None" for Date. However, no matter what I do, it insists on putting a date in with the time that I enter. What is SHOWS me is just the time, but if I double click on a cell I can see that it has embedded a date as well. I realized this when the graph I had created from this data went from working as expected to showing very weird and seemingly unexplainable data. Then I realized that the first several days worth of data that I had put in all at once had the date encoded into those cells of the date I created the spreadsheet, but as days went by and I entered new time data it would silently add a date to each cell that was the date I entered info into that cell.


If I manually double click into each cell and set every single one to have a date that matches the original data (so that all time cells have the same hidden date embedded in them) then the graph works fine.


But this is ridiculous. It works in the Date column for it to not silently embed a time since I have Time set to "None" for that column. How can I force the columns with times to work the same way and to respect that I have set Date to "None" for those columns?

Posted on Feb 26, 2024 12:45 PM

Reply
Question marked as Top-ranking reply

Posted on Feb 26, 2024 9:07 PM

You could consider laying out your data table something like this:




Columns A, B, and C are for input. They are formatted as Date & Time. Time is hidden in Column A, Date in Columns B and C.


In D2, filled down the column:


=DAYNAME(WEEKDAY(A2))


In E2, filled down and right to column F:


=DATEVALUE($A2)+TIMEVALUE(B2)


In G2, filled down:


=DATEVALUE(A2)


In H2, filled down:


=MOD(F2−E2,"1d")


When you set it up this way you can just enter the "dates" and "times" in the input columns and not worry about the hidden values that might disturb your calculations and charts. The MOD automatically accounts for a possible crossing midnight problem, but of course doesn't anticipate two all-nighters in a row!)


You can of course hide E, F or other columns after everything is up and working.


The chart in the example is 2D Scatter, something like this:





The Pivot Table (via Organize > Create Pivot Table > On Current Sheet) is set up like this in the example:




A Pivot Table takes maybe 2 minutes to set up (no formulas!) and can be quickly configured in any which way. Want Maximum or Minimum or fancier? Just add them.




And of course you can also make a chart based on a Pivot Table.


Intro to pivot tables in Numbers on Mac – Apple Support (UK)



SG


Similar questions

14 replies
Question marked as Top-ranking reply

Feb 26, 2024 9:07 PM in response to Thematteartist

You could consider laying out your data table something like this:




Columns A, B, and C are for input. They are formatted as Date & Time. Time is hidden in Column A, Date in Columns B and C.


In D2, filled down the column:


=DAYNAME(WEEKDAY(A2))


In E2, filled down and right to column F:


=DATEVALUE($A2)+TIMEVALUE(B2)


In G2, filled down:


=DATEVALUE(A2)


In H2, filled down:


=MOD(F2−E2,"1d")


When you set it up this way you can just enter the "dates" and "times" in the input columns and not worry about the hidden values that might disturb your calculations and charts. The MOD automatically accounts for a possible crossing midnight problem, but of course doesn't anticipate two all-nighters in a row!)


You can of course hide E, F or other columns after everything is up and working.


The chart in the example is 2D Scatter, something like this:





The Pivot Table (via Organize > Create Pivot Table > On Current Sheet) is set up like this in the example:




A Pivot Table takes maybe 2 minutes to set up (no formulas!) and can be quickly configured in any which way. Want Maximum or Minimum or fancier? Just add them.




And of course you can also make a chart based on a Pivot Table.


Intro to pivot tables in Numbers on Mac – Apple Support (UK)



SG


Feb 26, 2024 2:44 PM in response to Thematteartist

I don't know what your chart is exactly but you are right that a chart of text data doesn't get you anywhere. I'm kind of surprised Numbers doesn't convert it to date&time in the chart. It will convert text formatted numbers to actual numbers when they are charted but I guess not time of day.


One option is to create additional columns where you convert the text time to date&time with today's date


=TODAY()+TIMEVALUE(B2)


Chart those columns instead. You can hide them after you get it all set up. Make sure "hidden data" is checked for the chart or it will go blank again. Alternatively, you can make those columns a separate table, use that table for the chart, and put that table on another sheet.

Feb 27, 2024 6:39 PM in response to Thematteartist

If you are keeping it as date&time,


  • Change the formulas to be like =DATE(1,1,1)+TIMEVALUE(B2) , using the correct cell references of course. The columns need to have a steady date so that you can set the min and max on the Y axis. TODAY() changes every day but 1/1/0001 is always 1/1/0001.
  • Set Y min to 1/1/0001 0:00
  • Some choices for Y max and steps:
    • 1/1/0001 22:00 with 11 steps
    • 1/1/0001 21:00 with 7 steps
    • 1/1/0001 20:00 with 10 steps
    • 1/2/0001 0:00 with 12 steps (top number on Y will be 0:00 but all 24hrs will be on the chart)



Feb 27, 2024 9:50 PM in response to Thematteartist

Thematteartist wrote:

I haven't have any problems at all with calculating the time slept or graphing that. It was graphing the beginning sleep time and the waking time that was causing me problems.


To give you more ideas I've added some columns and a chart:




The trick, as you no doubt have discovered by now, is to "normalize" the times of day for the y-axis so they're all on the same date. Today is as good as any, and updates automatically, so I do that here with this in I2, filled right and down:


=TODAY()+TIMEVALUE(B2)


The vertical lines in the chart are created with Error Bars referring to the 'Seconds slept...' column (K). In K2, filled down is:


=DUR2SECONDS(H2)


I couldn't find a way to make the error bars work well when crossing midnight. To turn them off click them in the chart and choose 'None' in the dropbox in the inspector pane at the right). Without them the chart should still be useful to show the patterns.


Charts in Numbers are endlessly versatile. But they're also fiddly and time-consuming to create. It can take a lot of experimentation to get them to do the right thing. (Changing the steps in the Axis tabs is particularly important). And who knew you can add seconds to a time to create an error bar?


To save time recreating any of this, here is the Numbers document for this example (Dropbox download).


SG

Feb 26, 2024 2:20 PM in response to Thematteartist

One useful thing I just learned, however, is that if I switch those 2 time columns to Text and then back to Date & Time it resets all of the hidden embedded dates to today's date. So that's a super fast (though dumb) work around to needing to manually double click into fields and change the otherwise invisible date to match all earlier dates. So.... Huzzah?

Feb 26, 2024 2:12 PM in response to Badunit

Interestingly, if I format those two time columns as "Text" rather than "Date & Time" another column where I subtract one column from the other to get the total amount of time slept actually does still work, which surprised me. That seemed quite hopeful, but then I scrolled down and suddenly the chart made no sense whatsoever. Instead of showing a 24hr time range as the y-axis and having lines for the data the y-axis was showing 0, 1, 2, 3, and 4 with no lines for the data at all. I'm baffled about why the y-axis changed to that and why it no longer shows data.


Also, why is the "Date & Time" format insisting on including a date on these time columns, even though I have Date set to "None" whereas the same format works as expected on the date column and does not insist on a time being there since I have Time set to "None"? It seems like those should work the same way. There is no secretly embedded time data in the Date column cells. Why does it insist on secretly embedding date data in the Time column cells?


Is it a bug? Dumb implementation? Or is there some reason on insisting on a date being there even if I have Date set to "None"?

Feb 26, 2024 2:45 PM in response to Badunit

It occurs to me that I can take screen shots and include them so it's easier to see what I'm doing.


I tried creating columns that were =TODAY(A2)+TIMEVALUE(B2) like you suggested, but then the chart is more or less lines going up and to the right because the y-axis includes incrementally increasing dates in addition to the times.


If the "Sleep Start" and "Awake" columns could just have times in them and no embedded date (which is what I visually see in the cells when Date is set to "None") then it would chart the lines as enclosed, which is what I want. However, since it embeds a date regardless of having Date set to "None" in the formatting, I have to ensure that the dates on all of the cells are the exact same date. Otherwise the chart is whacked.



Feb 26, 2024 4:16 PM in response to Yellowbox

Thanks Ian. A good suggestion for sure, but alas... my child (a teen, really) never goes to sleep before midnight so that's not the issue. ;-)


And for what it's worth, if the Numbers development or testing team were ever to look at this thread, which is exceedingly unlikely, I switched to Numbers from Excel because I could never ever get the chart to work properly in Excel. So huzzah for numbers!


If nothing else, now that I've realized that switching those two time columns to Text format and then back to Date & Time format changes the dates on every one of the cells to the current date, I at least have an easier work around than double clicking into each cell and changing the date manually.

Feb 26, 2024 6:07 PM in response to Badunit

Actually, the chart brings up a different problem. Formatting the Y axis so it looks good may not be possible with the times as date&time. So.... change of plans. First though, if the Y axis goes from midnight to midnight do you want it to be 0:00 to 0:00 (counts up then the top number is 0:00, which is the next day) or 0:00 to 24:00? The first can still use date&time. The second I am thinking of converting the times to durations.

Feb 27, 2024 5:53 PM in response to SGIII

@SGIII - Wow! I learned some things following along with that. Thanks! And as long as I've been diving into Numbers for this, I may as well learn to use pivot tables on Numbers. Thanks for the link.


Interestingly, perhaps surprisingly, I haven't have any problems at all with calculating the time slept or graphing that. It was graphing the beginning sleep time and the waking time that was causing me problems.


I'm doing this to give visuals to my child's doctors so they can more easily/visually see the bigger picture patterns and the effects of medications. I'm happy to stare at a spreadsheet and I can see the patterns from that alone, but my child or the doctors... Not so much.

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.

How can I prevent a Time formatted cell from also having a date in it?

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