Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

datediff() vs Excel time discrepancy

Status
Not open for further replies.

Sharkfin01

Programmer
Sep 26, 2001
13
GB
When I use datediff() to find the number of days between now and Jan, 1, 1900, I'm off by roughly 2 days (and of course, whatever fraction of a day)..is there anyway I can fix this? i.e. get the same number as Excel would give if I converted a cell with 10/10/2001 12:00:00 to a number with 5 decimal places? Thanks
 
DateDiff will give you whatever you specify as the interval. I don't think it will return fraction of days.

You could use:

DateDiff("n", CDate("01/01/1900"), Now)

which will give you the minutes, and then work from there.

60 minutes in 1 hour,
24 hours in 1 day.

I'm not exactly sure what you want though _________________
Bixarrio
e = m * (c ^ 2)
 
I tried a similar approach where I just used datediff() and converted my date into seconds since Jan 1, 1900. However, when I convert back to days (standard divide by 3600 then by 24) I'm "short" of the Excel day by 2 days. Thanks
 
I just did the same:

1) Converted a cell with 10/10/2001 to a number with 5 decimal points.

2) Did a DateDiff("d", "01/01/1900", "10/10/2001")

For 1) I got: 37,174.00000
For 2) I got: 37,172.00000

I am stunned. _________________
Bixarrio
e = m * (c ^ 2)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top