Date difference expression in microsoft access

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • phoebe77
    New Member
    • Jun 2014
    • 1

    Date difference expression in microsoft access

    Code:
    Expr1:DateDiff("yyyy" [Visit Date]-[DOB])
    What am I doing wrong?? operand without an operator... what does this mean?
    Last edited by NeoPa; Jun 29 '14, 11:19 PM. Reason: Added tags
  • Stewart Ross
    Recognized Expert Moderator Specialist
    • Feb 2008
    • 2545

    #2
    DateDiff takes three arguments: the type of difference it is to return, and the two dates it is to compare. You have these, but you are not separating the arguments with commas. There is also no need to subtract one date from the other - that defeats the purpose of using Datediff.

    YearDiff: DateDiff("yyyy" , [Visit Date], [DOB])

    If the date difference in years returned is negative just swap the visit date and DOB arguments over.

    -Stewart
    Last edited by Stewart Ross; Jun 18 '14, 06:53 AM.

    Comment

    Working...