Results 1 to 5 of 5
  1. #1
    tanyalee123 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Oct 2013
    Posts
    51

    Question Weird Age Calculation

    Hi all, I'm trying to create an age field using the birthdate, but the birthdate is in the following format yyyymmdd, and everything I try, I get an error. I should have switched the birthdate around when I loaded in the date to read better, but now I have over 100,00 records, so that ship has sailed lol.



    So I just want to put an age field in the user's main form so they can see the actual current age. I also want to use it to show actual age when they run reports, so I would use it in queries as well.

    Thank you,
    Tanya
    Happy Friday!!

    Note...this is what I've used in other databases, but I don't know how to make it work with this particular birthdate.
    Age: DateDiff("yyyy",[BirthDate],Date())+(Date()<DateSerial(Year(Date()),Month([BirthDate]),Day([Birthdate])))

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    So this data is in a text field? Will have to use string manipulation functions to rearrange the date parts.

    Assuming the date values are all 10 characters, like: 2000/03/07

    DateSerial(Left([BirthDate],4), Mid([BirthDate],6,2), Mid([BirthDate],9,2))
    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
    tanyalee123 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Oct 2013
    Posts
    51
    Yes its a text field, but there are no slashes or dashes - 19971231

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Okay, then adjust the Start argument for the Mid functions.
    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.

  5. #5
    tanyalee123 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Oct 2013
    Posts
    51
    Thank you, as always!!

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

Similar Threads

  1. I have a question maybe somewhat weird
    By azhar2006 in forum Access
    Replies: 3
    Last Post: 03-04-2014, 03:34 AM
  2. Calculation Field in table vs Query calculation
    By Leonidsg in forum Database Design
    Replies: 18
    Last Post: 02-28-2013, 09:38 PM
  3. Another Weird Problem
    By ksmith in forum Access
    Replies: 16
    Last Post: 07-24-2012, 10:45 AM
  4. Weird Problem
    By ksmith in forum Access
    Replies: 5
    Last Post: 11-09-2011, 11:26 AM
  5. Weird Error
    By KevinMCB in forum Access
    Replies: 1
    Last Post: 02-16-2011, 02:23 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