Year=DateDiff(yyyy,Now()-[Entry Date]) Why not work? Access

G

Guest

Access 2003 - want to calculate the difference in years between now and the
date the students started college.
 
E

Ed Robichaud

First, your messages will be read and responded to better when you don't
bury part of the message in the subject line.

For your expression try:
=DateDiff("yyyy", [Entry Date], Date())

Review VBA Help (open any form/report in design mode, select view code, then
F1, then search for DateDiff function) for DateDiff syntax and examples.
-Ed
 
W

Wayne Morgan

You're close, try:

Year=DateDiff("yyyy", [Entry Date], Date())

Now() should also work instead of Date(), the difference is that Now() also
returns the current time in addition to the date, but since you're dealing
with years, the time would be ignored.

Be aware, the month and date will be ignored also. For example, if today is
September 15 and the date in Entry Date is 3 March 2002 or 3 December 2002,
you will get 3 as a result.
 
G

George Nicholson

You aren't giving the function the required information.
DateDiff(Interval, Date1, Date2)

Try this if you expect a positive number
DateDiff("yyyy", [EntryDate], Now())
or this if you want a negative number
DateDiff("yyyy", Now(), [EntryDate])

HTH,
 
G

Guest

Hello Maria
I sugest you see my proposal in microsoft.public.access.modulesdaovba
Good Luck
 

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