Unexpected result using Datediff

G

Gerardo

I'm trying to work with graphs and dates, in my code I'm using Datediff to
get the serial number for a given date and then graph the value. The problem
is that the difference between 04/01/2008 (mm/dd/yyyy) and 01/01/1900 is
giving the serial number of 2 days earlier. I know that I should add one to
get the serial number for April 1st 2008, instead I'm getting the serial
number for March 31st 2008.

Isn't this odd?
 
H

Howard Kaikow

Gerardo said:
I'm trying to work with graphs and dates, in my code I'm using Datediff to
get the serial number for a given date and then graph the value. The problem
is that the difference between 04/01/2008 (mm/dd/yyyy) and 01/01/1900 is
giving the serial number of 2 days earlier. I know that I should add one to
get the serial number for April 1st 2008, instead I'm getting the serial
number for March 31st 2008.

Isn't this odd?

1900 was not a leap year, that may account for the difference of 1.
 
G

Gerardo

Thank you, that was interesting, the funny thing is that within a worksheet,
calculating the difference using cells works just fine.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top