Thread: Time issue
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default Time issue

You are saving just the time and not the date. Excel time is stored as a
Number with Jan 1, 1900 = 1 and everyday after equals 1. 39771 is Nov 19,2008.

A day starts at midnight and one hour is = 1/24. One minute is 1/(24 * 60).
You have stored just the time on your worksheet which excel defautls to Jan
1, 1900. there is nothing wrong with this as long as you format the
worksheet as just time (without a date) and you don't need to compare the
time with previous days.

If you enter 12:00 it will be entered as .5 (1/2 day), 24:00 as 1, 36:00 as
1.5.

If you need to use the date then you have to enter the date with the time.
You have the option of formating at Date/time (11/19/08 8:00 AM) in any
format you want. You can format to show the time without the date. Or you
can format to show the date without the time. Or you can have both the date
and time. When you enter a date excel defaults the time to midnight. when
you enter a time excel defaults the date to Jan 1, 1900.



"Mike H" wrote:

Can we see the code used to fill the data range?

Mike

"MJKelly" wrote:


Hi,

I am using code to fill data onto a ws and once the values have been
pasted, the format is changed to "hh:mm", however, time values which
occur before 06:00 also have the date (01/01/1900) added to them and
this means a calculation which determins the time between the start
and finish times does not work. Any ideas why excel is adding this
date data? If I overwright the time value the caluication works. The
code I am using to set the format is: -

With Selection
.NumberFormat = "hh:mm"
End With

can you help?
Regards,
Matt