Manage Learn to apply best practices and optimize your operations.

## Domino Resources - Part 2

### Looking for something else?

I was doing some web dev where I needed to calculated the age of a person. I did search the web for a coded solution but came across many convoluted ways involving reams of script and complicated calculations using days, months and years allowing for leap years etc. I thought about what was needed and came up with this very simple algorithm. It assumes there are three text fields on the form named Day, Month, Year. In pseudo (human!) code it goes like this:

Initial age = Year today - Year entered.
if the entered Month > the Month today then age -1 (ie
Birthday not arrived yet!)

and also

if the entered Month = the Month of today but the Day entered
is > the Day today then age -1.

CODE:
This translates in Notes formula as (for example in a button):

age := @year(@today) - @texttonumber(Year) ;
@if(@texttonumber(Month) > @month(@today) |
(@texttonumber(Month) = @month(@today) & @texttonumber(Day) >
@day(@today) ) ;
@set("age"; age-1);
NULL);
@prompt([ok];""; @text(age) )

Also, for the web in JavaScript:

doc = document.forms[0];

today = new Date();
age = today.getFullYear() - Number(doc.Year.value);

if (Number(doc.Month.value) > today.getMonth()+1 ) {
age = age -1;
}
else
if ( Number(doc.Month.value) == today.getMonth()+1 &&
Number(doc.Day.value) > today.getDate() ) {
age = age -1;
}

This was last published in November 2000

#### Start the conversation

Send me notifications when other members comment.

## SearchWindowsServer

• ### Server Core management remains a challenge for some

Server Core, the minimal Windows Server deployment, removes some admins from their GUI comfort zone, but its benefits reduce some...

• ### Meltdown and Spectre vulnerabilities dominate January Patch Tuesday

Complications surrounding the fix for the Meltdown and Spectre microprocessor architecture flaws will make the patching process ...

• ### Windows Server hardening still weighs heavily on admins

Windows Server hardening procedures drew renewed interest following the rash of ransomware outbreaks this year. See what tips on ...

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

• ### Three requirements for a hybrid cloud computing deployment

As the hybrid cloud computing approach gains steam, organizations will need to pay close attention to cross-cloud connectivity ...

• ### Five debunked myths about SSD issues

Solid-state drives are mature now, and the technology has eclipsed hard disk drives with superior performance, manageability and ...

• ### Future data center trends hinge on the edge, cloud and staffing

Edge computing, colocation, cloud and IT staffing issues lead the way as industry analysts make their predictions for the future ...

## SearchExchange

• ### Compliance Manager tool aims to ease security audit process

Administrators who wrestle with compliance tasks in Office 365 and Azure workloads might find some relief with Microsoft's ...

• ### Set Office 365 group limits to avoid administrative hassles

With help from PowerShell, administrators can tailor Office 365 Groups to develop common-sense restrictions on the tools and ...

• ### The top Exchange and Office 365 tutorials of 2017

Exchange Server remains a solid messaging choice, but interest in Microsoft's cloud platform shows no sign of abating. These ...

## SearchContentManagement

• ### Intelligent information management the next wave for ECM

In a 2018 upgrade, M-Files allows users to search for content in multiple repositories, while also being able to automatically ...

• ### SharePoint integration and implementation best practices

Here are some expert advice and tips, as well common definitions, to help make your SharePoint integration and implementation a ...

• ### SharePoint branding capabilities get a facelift

Since Microsoft Ignite last September, SharePoint Online is getting new branding capabilities that have been on the wish lists of...

Close