Results 1 to 3 of 3
  1. #1
    Jamesiv1 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Apr 2014
    Posts
    28

    Sum of today's year minus the year of a date in the past

    I'm trying to add a couple of fields to the Contact database in Access 2010.

    In the Contacts table, I created a field called "Sobriety Date" that has dates formatted like 12/27/1995

    I am trying to add a calculated field called "Years Sober" which should be the current year minus the year in the 'Sobriety Date' field (1995 in the example above).

    I have been trying to tweak this:

    SUM(DatePart("yyyy",[Date]) - DatePart("yyyy",[Sobriety Date]))

    but it's not working. Keeps giving me "The expression that you entered is not valid for web-compatible calculated columns"



    Please help?

    James

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,972
    Calculated fields in tables have limitations. Not many functions recognized. Will probably have to do this calc in query or in textbox on form/report.

    Use DateDiff function to calculate difference of dates. Also, Sum is an aggregate function. With exception of the row revealed at bottom of table by clicking the Totals button on ribbon, can't do aggregate calcs in table, it really makes no sense. Tables are for raw data.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Jamesiv1 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Apr 2014
    Posts
    28
    Thank you June7. Works great!

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

Similar Threads

  1. Dsum data between to dates for this year and last year
    By sdel_nevo in forum Programming
    Replies: 1
    Last Post: 06-13-2013, 06:48 AM
  2. Replies: 4
    Last Post: 01-09-2013, 11:16 AM
  3. Financial Year not Calendar Year
    By Kirsti in forum Queries
    Replies: 5
    Last Post: 05-02-2012, 09:11 PM
  4. Replies: 4
    Last Post: 01-10-2012, 06:26 PM
  5. Year over Year Comparision of Portfolio
    By richard70 in forum Queries
    Replies: 2
    Last Post: 10-31-2011, 08:19 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