[date_age]

Description

Link: [date_age]
Author: Steve Piercy
Category: Date
Version: 8.5.x
License: Public Domain
Posted: Mar. 01, 2010
Updated: Mar. 01, 2010
More by this author...
Returns age in years. By default the current date is used to determine age, but can be overridden by passing in a second date.

Parameters

-dob date, required Date of Birth
-end date, optional End date, default is current date

Sample Usage

date_age(-dob=date('2000-02-29'));
date_age(-dob=date('2000-02-28'),-end=date('2010-03-01'));
						

Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
define_tag('age', -description='Returns age in years.  By default the current date is used to determine age, but can be overridden by passing in a second date.',
	-namespace='date_',
	-required='dob', -type='date',
	-optional='end', -type='date',
	-priority='replace');
	!local_defined('end') ? local('end') = date;
	local('age') = #end->year - #dob->year - 1;
	if((#end->month - #dob->month == 0 && #end->day - #dob->day >= 0)
		|| #end->month - #dob->month > 0);
		#age+=1;
	/if;
	return(#age);
/define_tag;

 

Related Tags



Comments

none

Email:


Password:



Newest

Most Popular

Support tagSwap.net