A field with an identity crisis
I have a layout region with a pop-up calendar for the users' birthdays. I have another field that is supposed to calculate the users' ages. The age (number/computed) field has the following formula but it causes an error stating that it should be a date/time field. Unfortunately this also fails when I change it to date/time format:
@Text(@If(@Month(@Today) 
@Month(Birthday); @Year(@Today) - 
@Year(Birthday); @If(@Day(@Today) 
< @Day(Birthday);
 (@Year(@Today) - @Year(Birthday)) - 1; 
@If(Birthday = ""; "Ageless"; @Year(@Today) 
- @Year(Birthday)))))

    Requires Free Membership to View

    Register today to access targeted resources from our editorial writers and independent industry experts focused on Lotus Domino, Notes, Workplace and other related technologies.

    By submitting your registration information to SearchDomino.com you agree to receive email communications from TechTarget and TechTarget partners. We encourage you to read our Privacy Policy which contains important disclosures about how we collect and use your registration and other information. If you reside outside of the United States, by submitting this registration information you consent to having your personal data transferred to and processed in the United States. Your use of SearchDomino.com is governed by our Terms of Use. You may contact us at webmaster@TechTarget.com.

The check if the birthday field is empty or not is done at the end of the formula. In the event that birthday is empty, the beginning of your formula will fail. This is because your are performing date/time functions on an empty value, which is not allowed. Move the check for an empty Birthday field to the top of the formula. For instance:
@If(Birthday="";"Ageless";
<<<your formula here>>>)

Do you have comments on this Ask the Expert Q&A? Let us know.

This was first published in July 2003