Results 1 to 2 of 2

Thread: Access - problem with datediff

  1. #1
    Join Date
    Apr 2004
    Location
    Arizona
    Posts
    2

    Access - problem with datediff

    I am trying to design a query to determine an employee's length of employment in days.

    The table tblEmployeeInfo has a Date Hired field that uses dd/mm/yyyy format and I want Access to subtract that date from the current date and return the number of days.

    I've read everything I could find on the DateDiff() function, but everything I've tried so far has resulted in various syntax related error messages. Does my table (or query) need a current date field? Do I then need to subtract the value in one field from the other? How do I get this darn frustrating thing to work?

    Please be as specific as possible, I'm no expert on SQL or VB code.

    Thanks for your help.
    Rob

  2. #2
    Join Date
    Apr 2004
    Location
    Arizona
    Posts
    2
    Hi Guys,

    Let me re-state the question. Using the expression builder, I set the criteria for a calculated date field in a query as follows:

    DateDiff("d",[tblEmployeeInfo]![Current Date],[tblEmployeeInfo]![Date of Hire])

    When I run the query I get an error message "type mismatch in expression". I've checked the format of the two date fields in the underlying table and they are both in short date format. Any idea about what is wrong?

    Thanks for any help you can provide.

    Rob

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •