Results 1 to 4 of 4
  1. #1
    BADebbie is offline Advanced Beginner
    Windows 8 Access 2010 64bit
    Join Date
    Jul 2015
    Posts
    33

    Create Total Years column in a Query


    I have a column with a Hire Date, and I want to create a Total Years column. I have tried the following expression, but it didn't work.
    =(TODAY()-HireDate)/365.25

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    you do date math with DATEADD, or DATEDIFF

    =DATEDIFF("d",HireDate,Date())/365.25
    or
    =DATEDIFF("yyyy",HireDate,Date())

  3. #3
    BADebbie is offline Advanced Beginner
    Windows 8 Access 2010 64bit
    Join Date
    Jul 2015
    Posts
    33
    I got my answer. it is this expression.

    Years of Service: DateDiff("yyyy",[Hire Date],Now())+Int(Format(Now(),"mmdd")<Format([Hire Date],"mmdd"))

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    For the record, your method would work, but there is no TODAY() function. You want Date():

    ?(Date()-#1/1/2000#)/365.25
    16.8569472963723
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 9
    Last Post: 03-02-2015, 06:05 PM
  2. Total Column in Query
    By spoolinaz in forum Access
    Replies: 10
    Last Post: 01-03-2014, 12:26 PM
  3. Use of Query Column Total in an expression
    By Hawthorne62 in forum Access
    Replies: 10
    Last Post: 01-21-2013, 02:05 PM
  4. Replies: 7
    Last Post: 04-27-2010, 02:47 PM
  5. Replies: 1
    Last Post: 03-15-2007, 03:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums