Q

Is there a LotusScript function to calculate age given a date of birth?

Is there any function to calculate the age by the given date of birth. Is there a date interval, dateadd, datesub etc. function in LotusScript as there is in VB Script? In LotusScript there are two ways to represent dates -- using a date/time variant or a NotesDateTime object. Both types support a "subtract" operation. With the date/time variant, this is the "-" operator, such as: daysOld = doc.DateOfBirth(0) - Today ' returns their...

age in days.

With NotesDateTime objects you can use TimeDifferenceDouble or TimeDifference.

However, knowing the person's age in days doesn't automatically tell you their age in years, because not all years have the same number of days. The following function determines the age by checking whether their birthday has already occurred this year. The function comes from the Notes Design Library which you can download from LDD Sandbox.

Function age(dob, asofdate)
 ' the arguments are assumed to be of type LotusScript date/time.
 Dim dyr%, dmo%
 dyr = Year(asofdate) - Year(dob)
 dmo = Month(asofdate) - Month(dob)
 If dmo < 0 Or (dmo = 0 And Day(asofdate) < Day(dob)) Then ' their birthday 
has not yet arrived this year.
 age = dyr - 1
 Else
 age = dyr
 End If
End Function 

This was first published in May 2003

Dig deeper on LotusScript

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

SearchDataCenter

SearchExchange

SearchContentManagement

Close