On Mon, 1 Jul 2024 18:09:51 +0100, Graham J wrote:
I have a table like this:
Date Time-of-day
01/07/2024 12:30
02/07/3024 14:45
etc.
I use the Excel format-cell function to display the date and time correctly.
I want a scatter chart with date along the X-axis and Time-of-day on the Y-axis. The date range should cover just the values in the Date column.
But when I try to create it I get Y-axis showing the date, starting at 01/01/1990 - so totally not what I want. The X-axis shows the number range.
After much experiment:
Date Time-of-day
01/07/2024 12.50
02/07/2024 14.75
etc.
... with the Time-of-day custom formatted as NUMBER 00.00 the scatter
chart displays correctly. The time is hours plus decimal proportions of
an hour for minutes, which I can live with.
Is this a known bug?
Does it work properly on more modern versions of Excel?
Is there a more appropriate group where I should post this?
Not a bug, known or unknown. As far as I know, the storage format of
dates and times hasn't changed since about Excel 5. (I'm currently
running Excel 2010, but when I was in tech support I also had Excel
2013 and 2016, and they handled dates the same as 2010.)
The first thing to bear in mind is that a date and/or time is not an
actual data type, like Integer or Double Precision. Rather, it's a
number, coding date alone, time alone, or date and time -- the format
can be number or date/time, but the bits of the number are the same.
* A date with no time is a whole number, the number of days after 31
December 1899. Day 1 in the Microsoft era was 1 January 1900, and
today (2 July 2024) is day number 45475. If you format the number as
a date, it's a date; if you format the _same_ number as a number,
it's not a date. But the stored bits don't change.
* A date with a time is a number with a fractional part. The integer
part is interpreted the same as in the previous paragraph. The
fractional part is the part of a day that runs from midnight to the
time: multiply that fractional part by 24 to get hours and fractional
hours. For example, 45474.75 is 0.75 or 3/4 of the way through 2 July
2024. =24*.75 = 18 hours, namely 6 PM on that date.
* A time with no date is a decimal between zero and 1. It can be
interpreted like the time in the preceding paragraph, or like an
amount of time rather than a time of day you'd read off of a clock.
Thus 0.75 formatted as a time can be regarded as 6 PM on an
unspecified day, or 18 hours because 24*0.75 = 18.
Microsoft set up dates and times this way so that you could add a
number of days to a date and/or time, or subtract one, and get the
appropriate answer. Example: =TODAY()+6.5 is 12 noon (0.5*24 = 12
hours) 6 days after today, and TODAY()-0.25 is 6 PM yesterday. (0.25*
24 = 6 hours, but _before_ the beginning of the current calendar
day).
What time is it 11 hours and 42 minutes after 1:15 PM? Solution:
a. 11 hours and 42 minutes is (11+42/60) hours or (11+42/60)/24 =
0.4875 of a day..
b. 1:15 PM is (13+15/60)/24 hours or (13+15/60)/24 = .552083333333333
of a day past midnight.
c. Add the two and you get 1.03958333333333 days past midnight, or 0.03958333333333 days past midnight of the following day; formatted
as a time that's 12:57 AM of that day.
Your 12.50 and 14.75 are 12-1/2 and 14-3/4 hours past midnight, if I
understand your notation correctly. While they got the job done, you
didn't need to reinvent the wheel. Your 12.50 could have been
=12.50/24 and would then have displayed as 12:30 PM with a normal
Microsoft time format. Similarly, =14.75/24 displays as 12:45 PM.
--
Stan Brown, Tehachapi, California, USA
https://BrownMath.com/
Shikata ga nai...
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)