Access Access, problem with query.

Joined
Nov 25, 2013
Messages
5
Reaction score
0
Hello I am trying to write a query that will find the different between the current date which the user will enter and a date which is already in my database (date of birth). I have a field called Date of birth in my staff information table to store this information.

Here is my query,

DateDiff("[Staff Information]![Date of birth]", "[Current Date]")

Currently it is returning this error: "The expression you entered has a function containing the wrong number of arguments."

I'm not sure what is missing from my query.

Please help! :)
 
Joined
Mar 20, 2012
Messages
764
Reaction score
4
Hi Matt and welcome to the forums! Try the below formula (assuming you're looking for the difference in the dates in years):
DateDiff("y",[Staff Information].[Date of birth],Now())

You were missing the argument telling you what increment you wanted to find the difference in. You also would have run into problems if [Current Date] is not a field. Using the Now() function allows you to have that calculated on a daily basis. Let me know if this does it for you!
 
Joined
Nov 25, 2013
Messages
5
Reaction score
0
Hi, thank you for the quick response. I should of mentioned I have another query which is "Like '' & [Enter Forename To Search]", the table is Staff and the field is "Staff Forename" this works correctly on it's own but it does not work with the other query. I'll attach some screenshots.
 

Attachments

  • 1.png
    1.png
    30.7 KB · Views: 147
  • 2.png
    2.png
    15 KB · Views: 136
Joined
Mar 20, 2012
Messages
764
Reaction score
4
How does it not work? Are you getting an error? No results? No prompt for a name? If you provide a bit more info, I may be able to help out.
 

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