Re: Issues with Datediff function

Tech-Archive recommends: Fix windows errors by optimizing your registry



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
.



Relevant Pages

  • Re: Issues with Datediff function
    ... James. ... between them using the datediff function. ... I was kinda hoping for 5 years. ... Dim intYears As Integer ...
    (microsoft.public.access.modulesdaovba)
  • Re: Last nights funniest moment
    ... Survior history" about Jason. ... I messed this up, kinda. ... The quote was James saying something along the ... James rocks and I'll be kinda rooting for him, ...
    (alt.tv.survivor)
  • Re: Bonging the nymphs
    ... James wrote: ... Heh. ... it would kinda make sense if they had to stay naked to keep their powers. ...
    (rec.games.roguelike.nethack)
  • Re: Why David Gilmour is better than you are.
    ... SotR wrote on 12/07/2009: heard him tho. ... Yes of course but what percentage of those people outside of the musician ... Kinda like, who hasn't heard James Jamerson's playing. ...
    (alt.guitar)
  • Re: FA Copper Coins of Europe vintage collecting book 1900 s
    ... At least that's kinda what it looks like to me. ... It was not my intention to suggest that the item could be had cheaper, ... rather to help identify the date of publication. ... James ...
    (rec.collecting.coins)