Help with DateDiff

A

Antney

How do I subtract the current date from a date in a table field?

I have dates in a field, e.g. 7/15/1980, and in my query, I have the current
date, Date(). I am trying to subtract the two and get the age in years. My
function works, but I am getting a message box, stating that I don't have
Date() as one of my tables parameters.

I want to get rid of the message box and have the query do the calculations
without any user prompts. Here is my function - Age:
DateDiff("yyyy",[DOB],[Date()])

Can anyone help me with this?

Antney
 
A

Antney

Of course!

Thank you!!

Ofer Cohen said:
Remove the square brackets from the date function, other wise it will look
for a field with this name

DateDiff("yyyy",[DOB],Date())

Also, see this link:

http://www.mvps.org/access/datetime/date0001.htm
Date/Time: Calculate Age of a person


--
Good Luck
BS"D


Antney said:
How do I subtract the current date from a date in a table field?

I have dates in a field, e.g. 7/15/1980, and in my query, I have the current
date, Date(). I am trying to subtract the two and get the age in years. My
function works, but I am getting a message box, stating that I don't have
Date() as one of my tables parameters.

I want to get rid of the message box and have the query do the calculations
without any user prompts. Here is my function - Age:
DateDiff("yyyy",[DOB],[Date()])

Can anyone help me with this?

Antney
 

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