+ Reply to Thread
Results 1 to 5 of 5

Convert Excel formula to Access

  1. #1
    Registered User
    Join Date
    11-17-2011
    Location
    South Africa
    MS-Off Ver
    Access, Excel 2010
    Posts
    52

    Convert Excel formula to Access

    Good day,

    Can anyone please help me to convert the following excel formula to an access formula:

    =DATE(LEFT(B1,2)+IF(LEFT(B1,2)<RIGHT(YEAR(TODAY()),2),2000,1900),MID(B1,3,2),MID(B1,5,2))

    B1 must be [IdNumber] in access - This is a 13 digit South African Id Number. This Excel formula extracts the date of birth (1975-02-22) from this number: 7502225048088
    It also compensates if a person was born in 1900's and 2000's. Any other sugestions would be helpfull.

    Above formula works in excel if you put the formula in cell C1 and the Id number in B1 (formatted as text to compensate for leading 00). I need something in access that does the same.

    Thank you

    SGT
    Last edited by SGT; 04-10-2014 at 04:58 AM.

  2. #2
    Registered User
    Join Date
    11-17-2011
    Location
    South Africa
    MS-Off Ver
    Access, Excel 2010
    Posts
    52

    Re: Convert Excel formula to Access

    ID Number breakdown:

    75 = year
    02 = month
    22 = day
    5 = gender

  3. #3
    Forum Contributor
    Join Date
    01-18-2010
    Location
    Bentley, NM
    MS-Off Ver
    Excel 2010
    Posts
    229

    Re: Convert Excel formula to Access

    All of those functions work in Access except maybe 'Today()'. Exchange that for 'Date()' and remove the '=' at the beginning and it should work. Of course replace the cell references with field references.

    It would probably make more sense to store the result of the function in another field in a table vs. calculating it on the fly each time you need it.

  4. #4
    Registered User
    Join Date
    11-17-2011
    Location
    South Africa
    MS-Off Ver
    Access, Excel 2010
    Posts
    52

    Thumbs up Re: Convert Excel formula to Access

    Thank you for the reply.

    I fiddled with it per your suggestion and found that this works:

    =Left([IdNumber],2)+IIf(Left([IdNumber],2)<Right(Year(Date()),2),2000,1900) & "-" & Mid([IdNumber],3,2) & "-" & Mid([IdNumber],5,2)

    Original:
    =DATE(LEFT(B1,2)+IF(LEFT(B1,2)<RIGHT(YEAR(TODAY()),2),2000,1900),MID(B1,3,2),MID(B1,5,2))


    The red was not necessary and i had to concatenate the red commas if that makes sence.

    For those who are lost, this formula is to get the Date of Birth (1982-12-25) from the id number 8212250058088 (South African Id Numbers). It is a formula for Access inside a query.

    Thanx maw230

  5. #5
    Forum Contributor
    Join Date
    01-18-2010
    Location
    Bentley, NM
    MS-Off Ver
    Excel 2010
    Posts
    229

    Re: Convert Excel formula to Access

    Glad you got it working!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Excel formula convert to ms access
    By joe8915 in forum Excel General
    Replies: 9
    Last Post: 10-22-2012, 12:58 PM
  2. Access Help, need to convert from excel!
    By avatsa88 in forum Access Programming / VBA / Macros
    Replies: 2
    Last Post: 08-12-2011, 01:44 PM
  3. CONVERT Excel Macro to Access?
    By gsurge in forum Access Programming / VBA / Macros
    Replies: 2
    Last Post: 06-01-2011, 11:12 AM
  4. Convert 500 Excel worksheets to 500 Access Tables
    By HMIExcel08 in forum Excel General
    Replies: 1
    Last Post: 04-14-2008, 09:49 PM
  5. [SOLVED] Convert EXCEL to ACCESS
    By marctupper in forum Excel General
    Replies: 2
    Last Post: 06-07-2005, 03:05 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1