+ Reply to Thread
Results 1 to 19 of 19

Excel Date of birth calculation from nic no

Hybrid View

  1. #1
    Registered User
    Join Date
    12-12-2012
    Location
    Sri Lanka
    MS-Off Ver
    Excel 2010
    Posts
    10

    Excel Date of birth calculation from nic no

    i want to calculate date of birth from that nic no, so this is the rules
    the first two characters show their birth year,
    the mid value(mid value means the 3rd, 4th and 5th character in that nic no) shows their date and month.
    that means
    january 31
    february 29
    march 31
    april 30..........etc (going through our normal calender, only February has 29 days for calculation like leap year calculation)

    eg:- some one born in 1995.03.15
    then their first two character of nic no is 95 and the next three character calculate with their birth month and day, that means
    1995.06.15
    six months
    january, february, march, april, may, june
    31+29+31+30+31+15=136
    now the first five nic no is 95136

    if this is male 136 (nic no = 95136)

    if this is female 136+500=636 (nic no = 95636)

    that means if that date of birth is for female then we add 500 with our normal calculation,
    so how to make a formula for this one in excel.
    if we want to add more than one column tell me what to do..

    also please help the other columns age and day of birth...


    anyways thanks in advance..
    Attached Files Attached Files
    Last edited by Dilshanth10; 12-12-2012 at 03:27 PM.

  2. #2
    Forum Expert Moo the Dog's Avatar
    Join Date
    09-28-2012
    Location
    Wisconsin
    MS-Off Ver
    Office 365 (PC & Mac)
    Posts
    1,845

    Re: Excel Date of birth calculation from nic no

    Here's a fun formula:
    Formula: copy to clipboard
    =(("19"&LEFT(A2,2))&"-"&IF(MOD(("19"&LEFT(A2,2))*1,4)=0,IF(B2>500,MONTH(B2-500),MONTH(B2))&"-"&IF(B2>500,DAY(B2-500),DAY(B2-1)),IF(B2>500,MONTH(B2-500),MONTH(B2))&"-"&IF(B2>500,DAY(B2-500),DAY(B2))))*1

    Note: Your addition in the 1st post is incorrect... day 136 is in May, not June.

    Try it and let me know.

    - Moo

    * Edit: While it works (for years prior to 2000), I'm glad I only spent about 15 minutes on that beast of a formula... daddylonglegs' solution is SO MUCH EASIER!
    Last edited by Moo the Dog; 12-13-2012 at 12:12 PM. Reason: Got to give credit to daddylonglegs for a great solution below!

  3. #3
    Registered User
    Join Date
    12-12-2012
    Location
    Sri Lanka
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Excel Date of birth calculation from nic no

    oh yaa
    thats my mistake

    thanks for your great support.....
    Last edited by Dilshanth10; 12-12-2012 at 04:39 PM.

  4. #4
    Forum Expert Moo the Dog's Avatar
    Join Date
    09-28-2012
    Location
    Wisconsin
    MS-Off Ver
    Office 365 (PC & Mac)
    Posts
    1,845

    Re: Excel Date of birth calculation from nic no

    january, february, march, april, may, june
    31+29+31+30+31+15=136
    Your addition in the quote above is incorrect. --> 31+29+31+30+31+15 = 167, not 136.

    The 136th day of the year (in a leap year) is May 15th, not June 15th.
    Jan+Feb+Mar+Apr ---> 31 + 29 + 31 + 30 = 121 with the remaining 15 days coming in May.

    - Moo

  5. #5
    Registered User
    Join Date
    12-12-2012
    Location
    Sri Lanka
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Excel Date of birth calculation from nic no

    can you make a formula for another two columns age and day of birth

    thanks one more...

  6. #6
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,736

    Re: Excel Date of birth calculation from nic no

    Just using the data in column A this formula will give you DOB assuming the correct number of days in February

    =DATE(LEFT(A2,2),1,MOD(MID(A2,3,3),500))

    (assumes DOB will be before 2000, but can be modified to cope with later dates)

    If you need to assume that February always has 29 days then try this version

    =EDATE(DATE(0,1,MOD(MID(A2,3,3),500)),LEFT(A2,2)*12)

    Edit: and for Age and Day of birth you can base that on the above so if DOB is in D2 use this formula in E2

    =DATEDIF(D2,TODAY(),"y")

    and in F2

    =TEXT(D2,"dddd")
    Last edited by daddylonglegs; 12-12-2012 at 04:56 PM.
    Audere est facere

  7. #7
    Forum Expert Moo the Dog's Avatar
    Join Date
    09-28-2012
    Location
    Wisconsin
    MS-Off Ver
    Office 365 (PC & Mac)
    Posts
    1,845

    Re: Excel Date of birth calculation from nic no

    Age: =DATEDIF(D2,TODAY(),"Y")
    Example results should be 17, 17 and 21

    - Moo
    Last edited by Moo the Dog; 12-12-2012 at 04:59 PM.

  8. #8
    Registered User
    Join Date
    12-12-2012
    Location
    Sri Lanka
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Excel Date of birth calculation from nic no

    thank you so much for your excellent work.....

  9. #9
    Registered User
    Join Date
    12-12-2012
    Location
    Sri Lanka
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Excel Date of birth calculation from nic no

    thanks for your great help..
    Last edited by Dilshanth10; 12-17-2012 at 02:08 PM.

  10. #10
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,736

    Re: Excel Date of birth calculation from nic no

    Is 95367 valid, why isn't that 96001?

    Did you try the second formula I suggested?

  11. #11
    Registered User
    Join Date
    12-12-2012
    Location
    Sri Lanka
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Excel Date of birth calculation from nic no

    thank you...
    Last edited by Dilshanth10; 12-17-2012 at 01:45 PM.

  12. #12
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,736

    Re: Excel Date of birth calculation from nic no

    Quote Originally Posted by Dilshanth10 View Post
    if this is male 136 (nic no = 95136)

    if this is female 136+500=636 (nic no = 95636)
    That's from your original post - from that I assume that the numbers will either be in the range 1 to 366 (male) or 501 to 866 (female). Is that incorrect? Making that assumption you shouldn't have a 367 should you?

    your formula is correct.. but b2>366 is change to b2>500
    Note that I was talking about the formula that I suggested (not Moo's formula), that doesn't use b2>366......

  13. #13
    Forum Expert Moo the Dog's Avatar
    Join Date
    09-28-2012
    Location
    Wisconsin
    MS-Off Ver
    Office 365 (PC & Mac)
    Posts
    1,845

    Re: Excel Date of birth calculation from nic no

    I would highly recommend using DADDYLONGLEGS' formula from Post #6 above.

    While my formula, with a few tweaks, can work fine - it is not the best way to solve your original problem.

    - Moo

  14. #14
    Registered User
    Join Date
    12-12-2012
    Location
    Sri Lanka
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Excel Date of birth calculation from nic no

    i see your formula once again... and you r correct friend... its my mistake... sry for that...
    your formula is 100% correct....
    but when u type 925001234v and it shows the date of birth 1992-1-0 ...
    do you have any idea to stop that calculation for 925001234v nic no...


    anyway thanks again...
    Last edited by Dilshanth10; 12-17-2012 at 01:41 PM.

  15. #15
    Registered User
    Join Date
    03-31-2022
    Location
    SL
    MS-Off Ver
    2019
    Posts
    1

    Re: Excel Date of birth calculation from nic no

    Can you share me the excel document?

  16. #16
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,049

    Re: Excel Date of birth calculation from nic no

    Quote Originally Posted by srktech View Post
    Can you share me the excel document?
    Administrative Note:

    Welcome to the forum.

    We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original.

    Please see Forum Rule #4 about hijacking and start a new thread for your query.

    If you are not familiar with how to start a new thread see the FAQ: How to start a new thread
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  17. #17
    Registered User
    Join Date
    09-09-2023
    Location
    Sri Lanka
    MS-Off Ver
    2013
    Posts
    1

    Re: Excel Date of birth calculation from nic no

    Could you please share the formula for the new NIC number?
    Last edited by spbuddharage; 09-09-2023 at 04:30 AM. Reason: typing error

  18. #18
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2505 (Windows 11 Home 24H2 64-bit)
    Posts
    91,209

    Re: Excel Date of birth calculation from nic no

    Administrative Note:

    Welcome to the forum.

    We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original.

    Please see Forum Rule #1 about hijacking and start a new thread for your query.

    If you are not familiar with how to start a new thread see the FAQ: How to start a new thread
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  19. #19
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,518

    Re: Excel Date of birth calculation from nic no

    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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