Results 1 to 5 of 5

Thread: How to calculate chronological age in Microsoft Excel

  1. #1
    Join Date
    Jun 2011
    Posts
    21

    How to calculate chronological age in Microsoft Excel

    I am trying to calculate chronological age - years and complete months - for school report purposes. I can get Years and months but not accurately - say for a date of birth 22nd November 1995 and a date of the 15th December - I get 9 years and 1 month.

  2. #2
    Join Date
    Jun 2009
    Posts
    321

    Re: How to calculate chronological age in Microsoft Excel

    There is a sample code which can help you for the process. The sample code is as follows :
    =DATEDIF(A1,NOW(),"y") & " years, " & DATEDIF(A1,NOW(),"ym") & " months, " & DATEDIF(A1,NOW(),"md") & " days".

    To use it with a given date (15 Dec 04) rather than the current date (Now()) use the following formula=DATEDIF(A1,B1,"y") & " years, " & DATEDIF(A1,B1,"ym") & " months, " & DATEDIF(A1,B1,"md") & " days" .

    Where A1 stores their birth date and B1 stores the date to compare to.

  3. #3
    Join Date
    Feb 2010
    Posts
    155

    Re: How to calculate chronological age in Microsoft Excel

    Your result would be 9 years and 23 days which Excel rounds to 9 years and 1 month. What would you like to have displayed. 9 years and 23/31 months. This formula will give you 9 years, 0 months, 23 days =DATEDIF(A1,A2,"y") &" years, "& DATEDIF(A1,A2,"ym")&" months, "& DATEDIF(A1,A2,"md") & " days". Where A1 holds earliest date.

  4. #4
    Join Date
    Feb 2010
    Posts
    658

    Re: How to calculate chronological age in Microsoft Excel

    Is there a way to put Gord formula into a VBA function and say name it YrsMthsDays whereby the formula would be =YrsMthsDays(A1,A2)

  5. #5
    Join Date
    Apr 2010
    Posts
    44

    Re: How to calculate chronological age in Microsoft Excel

    It would actually quicker to keep the formula in the worksheet. And if you keep the formula handy (in a text file or sample workbook or just a link to Chip's site), it wouldn't be too hard to copy it into your worksheet. But if you want...
    Code:
    Option Explicit
    Function YrsMthsDays(rng1 As Range, rng2 As Range) As Variant
    
    Dim iCtr As Long
    Dim myVals(0 To 2) As Long
    Dim myIntervals As Variant
    Dim myStrs As Variant
    Dim myOutput As String
    
    myIntervals = Array("y", "ym", "md")
    myStrs = Array(" years, ", " months, ", " days")
    
    myOutput = ""
    For iCtr = LBound(myVals) To UBound(myVals)
    myVals(iCtr) = Application.Evaluate("datedif(" _
    & rng1.Address(external:=True) _
    & "," & rng2.Address(external:=True) _
    & ",""" & myIntervals(iCtr) & """)")
    myOutput = myOutput & myVals(iCtr) & myStrs(iCtr)
    Next iCtr
    
    YrsMthsDays = myOutput
    
    End Function

Similar Threads

  1. Need help to calculate Average of time in Microsoft Excel
    By NardO in forum MS Office Support
    Replies: 2
    Last Post: 23-02-2012, 05:06 PM
  2. How to calculate ages in Microsoft Excel
    By vALaNCiA in forum MS Office Support
    Replies: 2
    Last Post: 17-02-2012, 06:17 PM
  3. How to calculate overtime in Microsoft Excel
    By Purujeet in forum MS Office Support
    Replies: 2
    Last Post: 15-02-2012, 08:11 PM
  4. Replies: 2
    Last Post: 07-02-2012, 05:56 PM
  5. How to calculate Autocorrelation in Microsoft Excel
    By connoisseur in forum MS Office Support
    Replies: 4
    Last Post: 18-01-2012, 05:43 PM

Tags for this Thread

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
  •  
Page generated in 1,713,528,675.85989 seconds with 17 queries