Results 1 to 2 of 2
  1. #1
    sgtyukon is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Posts
    1

    YEAR Function Doesn't Work Consistently in My Data Base

    I'm not very accomplished with Access.

    I have an Access 2016 data base of the music I own. It's a list of roughly 7,200 individual songs with various associated data. One of the fields, date, holds the date each song reached its highest chart position on the Billboard Top 100 in short-date format (mm/dd/yyyy).



    I wanted to extract the year from the date, so I added a new column I called Annum, because Access didn't like me trying to call it year.

    About half the records have a value in the date field. The remainder didn't reach the Billboard chart.

    In the design view and in the description column for Annum, I entered YEAR [(date)].

    It worked some of the time.

    It did return a year (incorrect) in the Annum column for a handful of records that don't have a value in the date column. It also returned a correct value in about 2,400 records that do have a value in the date field. And, the biggest problem, it returned no value for about 1,200 songs that do have a date entered in the date field.

    What am I doing wrong? How do I proceed to get a correct year from a correctly formatted date on every occasion, and no value for a record where the date field contains no entry?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    Try: Year([Date])

    Date is a reserved word (as is Year, both are intrinsic functions) and should not use reserved words as names for anything.
    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.

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

Similar Threads

  1. Function doesn't work
    By HS_1 in forum Programming
    Replies: 18
    Last Post: 05-10-2018, 07:33 AM
  2. Replies: 5
    Last Post: 01-21-2018, 04:06 AM
  3. Replies: 3
    Last Post: 09-19-2014, 07:58 AM
  4. Replies: 3
    Last Post: 01-07-2014, 09:57 AM
  5. Replies: 2
    Last Post: 01-03-2011, 05:17 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