Manage Learn to apply best practices and optimize your operations.

# Age Computation

This Content Component encountered an error

This function takes two inputs: a string representation of the date of birth
and the uidoc where the field is located. In this example, age is the name of
the target field.
The function does return an integer value, so it can be accessed readily
through the following call:
age = getage(dob\$, uidoc)
To use the code, just paste it in after the End Sub line of the calling script,
or tailor as you wish through script libraries.

If you have questions or problems, please feel free to contact me.
Function getage(temp_dob As String, uidoc As notesuidocument) As Integer

Dim message As String
Dim timenow As Variant
Dim dyear As Integer, nyear As Integer, dmonth As Integer, nmonth As Integer,
dday As Integer, nday As Integer
Dim age As Integer

'initialize values
Dim dob As Variant
dob = Datevalue(temp_dob)
timenow = Date
dyear = Year(dob)
nyear = Year(timenow)
dmonth = Month(dob)
nmonth = Month(timenow)
dday = Day(dob)
nday = Day(timenow)
If nmonth > dmonth Then
age = nyear - dyear
Elseif nmonth < dmonth Then
age = nyear - dyear - 1
Elseif nmonth = dmonth Then
If nday > dday Then
age = nyear - dyear
Elseif nday < dday Then
age = nyear - dyear - 1
Elseif dday = nday Then
age = nyear - dyear
End If
Else
message = "Unable to compute the person's age. Please enter it below."
age = Cint(Inputbox(message))
End If
Call uidoc.fieldsettext("Age",Cstr(age))
'doc.Age = Cstr(age)
'Call doc.save(True, True)
getage = Cint(age)
End Function

This was last published in November 2000

#### Start the conversation

Send me notifications when other members comment.

## SearchWindowsServer

IT workers need to learn how to ride the wave of innovation and master these five technologies related to Windows Server that can...

• ### Options for server management tools expand to meet IT needs

Not only do admins have to contend with a mix of server OSes, there are diverse scenarios to complicate their management. Learn ...

• ### CPU bugs add to IT stress as February Patch Tuesday drops

Administrators who rushed out fixes in January for the Meltdown and Spectre flaws then had to unwind some of those corrections ...

## 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 ...

## SearchDataCenter

• ### IBM Power9 servers seek market inroads to AI, cloud

IBM follows up its first Power9 server with a raft of systems designed to appeal to a wider array of markets -- most notably, AI ...

• ### Evaluate read-intensive and write-intensive SSD use cases

Consider write wear, performance and other factors when choosing between read-intensive, write-intensive and mixed-use ...

• ### Some hyper-converged infrastructure use cases pose pitfalls

Hyper-converged infrastructure adoption is skyrocketing, but that doesn't mean that the technology is the best choice for every ...

## SearchExchange

Everyone wants a smooth patching process, but things can fall apart despite everyone's best efforts. Develop a solid recovery ...

• ### New Office 365 administrators grapple with challenges

More enterprises mulling the move to Office 365 should factor in the adjustments necessary to get the IT department up to speed ...

• ### Curb stress from Exchange Server updates with these pointers

Some administrators let the memories of a bad patch linger and put off Exchange updates. Here are some tips to make this ...

## SearchContentManagement

• ### Content management in the cloud a main theme in 2018

The future of content management resides in the cloud and with AI, as several 2018 conferences will assure you.

• ### Six things to know about today's SharePoint implementations

As companies migrate their on-premises Microsoft SharePoint sites to the cloud, here are some things they should know about the ...

• ### Upgrades for the SharePoint Online portal

As more organizations migrate SharePoint sites to the cloud, Microsoft has increased at-a-glance dashboard data and analytics to ...

Close