Re: Issues with Datediff function
- From: Matthias Klaey <mpky@xxxxxxxxxxx>
- Date: Wed, 28 Jun 2006 20:10:21 +0200
James. <James@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
Ok, try not to laugh. I have two dates in VBA, I wish to find the years
between them using the datediff function.
date1 = #1/1/2000#
date2 = #1/1/2005#
date3 = DateDiff("yyyy", date2, date1)
When I run this date 3 is :
12/25/1899
I was kinda hoping for 5 years. I have changed the order of the date value
and still get an odd result. Can anyone tell me the silly mistake I am
making here please.
Thanks.
James D.
In the immediate window:
? DateDiff("yyyy", #1/1/2000#, #1/1/2005#)
5
The result from DateDiff is a Long, not a date. Assign the result to
an Long variable, not to date3.
HTH
Matthias Kläy
--
www.kcc.ch
.
- Prev by Date: Re: Random Selection
- Next by Date: RE: Tracking Log In and Log Out times of Users
- Previous by thread: RE: Random Selection
- Next by thread: Re: Issues with Datediff function
- Index(es):
Relevant Pages
|