Solved

# Date of Birth Formula

Posted on 2005-05-09
2,133 Views
Hi Experts,

Been trying Ken Hamadys age calculation formula...

I get an error?

DateVar Birth:= {sps_MIU_Ilkeston_crystal_template_data.child_dob};   // Replace this with your field for Date Of Birth
DateVar Ann := CurrentDate;  // Replace this with CurrentDate to get their age as of the time of the report
//or the date field of an event to get their age as of the time of that event.
if (Month(Ann) * 100) + Day (Ann) >=(Month(Birth) *100) + Day (Birth)
then Year (Ann) - Year(Birth)
else Year (Ann) - Year(Birth) -1

I get the error which prompts for a 'date is required here' in front of the {sps_MIU_Ilkeston_crystal_template_data.child_dob}
it is a datetime(8) in my sql sp!!
0
Question by:paulo111

LVL 100

Accepted Solution

>>I get the error which prompts for a 'date is required here' in front of the {sps_MIU_Ilkeston_crystal_template_data.child_dob}
it is a datetime(8) in my sql sp!!
That is the problem.  A DateVar is not a DataTiem and Crystal doesn't do automatic conversions

Try
DateVar Birth:= Date({sps_MIU_Ilkeston_crystal_template_data.child_dob});

mlmcc
0

LVL 1

Assisted Solution

Well, I don't know if this will help, but it's a bulletproof way of calculating age to whole numbers, I don't trust DATEDIFF you see...

if Month({Employees.Birth Date}) < Month(CurrentDate) or (Month({Employees.Birth Date}) = Month(CurrentDate) and Day({Employees.Birth Date}) <= Day(CurrentDate)) then Year(CurrentDate) - Year({Employees.Birth Date}) else (Year(CurrentDate) - Year({Employees.Birth Date}))-1

It's nothing to do with Crystal or any other software for that matter, it works if you check it on a blackboard nver mind with software.

Anyway, thought it might help

Regards

DAVE THE RAVE
0

LVL 100

Expert Comment

mlmcc
0

## Featured Post

### Suggested Solutions

There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
how to add IIS SMTP to handle application/Scanner relays into office 365.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…