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! :)
 
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!
 
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.webp
    1.webp
    27.9 KB · Views: 153
  • 2.webp
    2.webp
    5.4 KB · Views: 142
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.
 
Back
Top