[age]

Description

Link: [age]
Author: Jolle Carlestam
Category: Date
Version: 8.5.x
License: Public Domain
Posted: Mar. 01, 2010
Updated: Mar. 01, 2010
More by this author...
Returns the age as years calculated between to dates. It typically answers the question "How old are you|the dog|my car". The answer is derived by comparing the given "Date of birth" param (dob) with today. An optional "now" param can be used to answer the question "How old where xx at a given date". A Lasso 9 equivalent is also published on Tagswap

Parameters

-date date, required

Sample Usage

age(-dob=date('2000-02-28'),-dod=date('2010-08-27'));
age(-dob=date('2000-02-28'));
age(date('2000-02-28'),date('2010-08-27'));
age(date('2000-02-28'));
						

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
15
16
<?LassoScript

define_tag(
	'age',
	-description = 'Returns the age as years calculated between to dates.',
	-req = 'dob', -type = 'date',
	-opt = 'dod', -type = 'date'
);

	local('now' = local_defined('dod') ? date(#dod) | date);

	return(integer(#now -> year - #dob -> year) - ((integer(#dob -> month) * 100) + integer(#dob -> day) > (integer(#now -> month) * 100) + integer(#now -> day) ? 1 | 0));

/define_tag;

?>

 

Related Tags



Comments

none

Email:


Password:



Newest

Most Popular

Support tagSwap.net