Solved

Age Formula With Condition for No DOB Data

Posted on 2011-09-27
6
436 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
6 Comments
 
LVL 100

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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 100

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 34

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
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…
This video discusses moving either the default database or any database to a new volume.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

744 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now