Solved

Age Formula With Condition for No DOB Data

Posted on 2011-09-27
6
451 Views
Last Modified: 2012-05-12
Hello Experts,  
I am using the formula pasted below to calculate the age of a person.  Unfortunately, if no DOB data is entered for a person, the report will not print, etc.  Can you advise me of how to adjust the formula to handle the condition where no DOB is entered.  

// birthday feb 29 and current year is leap year

if month({CREntityDescriptors.DateOfBirth})=2 and day({CREntityDescriptors.DateOfBirth})=29 and

day(date(year({CRArrestees.ArrestedOn}),3,1)-1)=28

then

if date(year({CRArrestees.ArrestedOn}),month({CREntityDescriptors.DateOfBirth}),
day({CREntityDescriptors.DateOfBirth})- 1) > {CRArrestees.ArrestedOn}

then year({CRArrestees.ArrestedOn})-year({CREntityDescriptors.DateOfBirth})-1

else year({CRArrestees.ArrestedOn})-year({CREntityDescriptors.DateOfBirth})

else

// birthday not feb 29 or current year is a leap year

if date(year({CRArrestees.ArrestedOn}),month({CREntityDescriptors.DateOfBirth}),
day({CREntityDescriptors.DateOfBirth})) > {CRArrestees.ArrestedOn}

then year({CRArrestees.ArrestedOn})-year({CREntityDescriptors.DateOfBirth})-1

else year({CRArrestees.ArrestedOn})-year({CREntityDescriptors.DateOfBirth})


Thank you for any help.
~Chopp
0
Comment
Question by:Chopp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 36714309
Try this

If Not IsNull({CREntityDescriptors.DateOfBirth}) then
    your code
Else
    default age

mlmcc
0
 

Author Comment

by:Chopp
ID: 36714684
Thank you.
I tried this method, and I receive an error message that says,
'A month number must be between 1 and 12'.

Thank you for the idea.
Any other ideas, or an alternative age formula?


~Chopp
0
 
LVL 19

Accepted Solution

by:
GJParker earned 500 total points
ID: 36715593
Here is a simpler formula that will give an accurate age and handle the missing dates

WhileReadingRecords;
DateVar Birth := {CREntityDescriptors.DateOfBirth};
DateVar Arrested := {CRArrestees.ArrestedOn};

If Not IsNull({CREntityDescriptors.DateOfBirth}) Then                                  
    If (Month(Arrested) * 100) + Day(Arrested) >= (Month(Birth) *100) + Day(Birth) Then
        Year(Arrested) - Year(Birth)  
    Else
        Year(Arrested) - Year(Birth) -1

HTH
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 101

Expert Comment

by:mlmcc
ID: 36717410
WHere do you get the error?
If it is in the DATE(...) calculation then I suspect you may have some bad data

mlmcc
0
 
LVL 35

Expert Comment

by:James0628
ID: 36718478
The question is, if no DOB is entered, what value do you have in that field?  If it's null (no value), then mlmcc's suggestion should handle that, assuming that you don't have CR set to replace nulls with the default value.  If it's some other value, then we may need to know what that value is.

 James
0
 

Author Closing Comment

by:Chopp
ID: 36719294
Thank you very much!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question