I've been working on this problem for some time now, and while this i
the most common formula, it is not 100% accurate (at least on m
system).
I use the following formula:
excel = ((unix - timezone) / 86400) + 25569
where:
unix = seconds since Jan 1, 1970, midnight, GMT
timezone = offset in seconds for my timezone (PST = 28800)
86400 = seconds in one day
25569 = Excel value for DATE(1970, 1, 1)
In my test, my unix GMT time for right now is 1070994879. Uni
interprets this as: Dec 9, 2003 10:34:39 PST. Inserting this same uni
time into the above formula results in an Excel time of 37964.4414062
or 12/9/2003 10:35:37. There is a difference of 58 seconds that
cannot explain. Unfortunately, my application needs to be exact to th
second.
Could this be a precision or roundoff error??? Other??
Notes:
- the formula is calculated in a Unix C program, all vars are long o
float as appropriate.
- Excel v.9 (2000)
-with thanks,
Mike