BOFocus – Crystal Reports Tips – Tricks – Tutorials

Crystal Reports - Formulas

Age calculation

The following formula will allow you to calculate a person’s age correctly:

DateTimeVar begindate := CurrentDate;
DateTimeVar enddate := CurrentDate;

begindate := Date(Year(begindate), Month(begindate), 01);
enddate := DateAdd( “d”, -1, DateAdd(“m”, 1, enddate) );

If (Month(enddate) * 100) + Day(enddate) >= (Month(Date({BirthDate_Field})) * 100) + Day(Date({BirthDate_Field)) Then
Year (enddate) – Year(Date({BirthDate)) Else
Year (enddate) – Year(Date({BirthDate)) – 1;

Tagged , ,

2 thoughts on “Age calculation

  1. Sumit Saha

    The following is working perfectly OK in Crystal report
    If (Not(isNull({DataTable2.dbirth}))) Then
    ToText(int(DateDiff(‘d’,DATE({DataTable2.dbirth}),CurrentDate())/365.25),0)+’ Years ‘+
    ToText(int(remainder(DateDiff(‘d’,DATE({DataTable2.dbirth}),CurrentDate()),365.25)/30),0)+’ Months ‘+
    If day(CurrentDate()) < Day({DataTable2.dbirth}) Then
    ToText(day(dateserial(year({DataTable2.dbirth}), Month({DataTable2.dbirth})+1,1-1)) – Day({DataTable2.dbirth}) + Day(CurrentDate()),0) + ' days'
    ToText(day(CurrentDate()) – day({DataTable2.dbirth}),0) + ' days'


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>



The Left Outer Join includes all records in the primary table that have an exact match in the secondary table but also all records that don’t have a match in the secondary table. The Left Outer and Right Outer joins are useful when creating reports to find participants without information in their record.