ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Unexpected result using Datediff (https://www.excelbanter.com/excel-programming/411545-unexpected-result-using-datediff.html)

Gerardo

Unexpected result using Datediff
 
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?

Norman Jones[_2_]

Unexpected result using Datediff
 
Hi Gerardo,

See Chip Pearson at:

Dates And Times In Excel
http://www.cpearson.com/excel/datetime.htm#AddingDates

See particularly the section entitled:

How Excel Stores Dates And Times



---
Regards.
Norman



"Gerardo" wrote in message
...
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?



Howard Kaikow

Unexpected result using Datediff
 
"Gerardo" wrote in message
...
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.



Gerardo

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

"Norman Jones" wrote:

Hi Gerardo,

See Chip Pearson at:

Dates And Times In Excel
http://www.cpearson.com/excel/datetime.htm#AddingDates

See particularly the section entitled:

How Excel Stores Dates And Times



---
Regards.
Norman



"Gerardo" wrote in message
...
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?




All times are GMT +1. The time now is 08:19 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com