Difference between revisions of "Age"

From Sega Retro

m
Line 1: Line 1:
<includeonly>{{#if: {{{2|}}} | {{#var_define:date2_y|{{year|{{{2}}}}}}}{{#var_define:date2_m|{{month|{{{2}}}}}}}{{#var_define:date2_d|{{#sub:{{{2}}}|8|2}}}} | {{#var_define:date2_y|{{CURRENTYEAR}}}}{{#var_define:date2_m|{{CURRENTMONTH}}}}{{#var_define:date2_d|{{CURRENTDAY}}}} }}{{#ifexpr: {{#var:date2_m}} > {{month|{{{1}}}}}
+
<includeonly>{{#if: {{{2|}}} | {{#vardefine:date2_y|{{year|{{{2}}}}}}}{{#vardefine:date2_m|{{month|{{{2}}}}}}}{{#vardefine:date2_d|{{#sub:{{{2}}}|8|2}}}} | {{#vardefine:date2_y|{{CURRENTYEAR}}}}{{#vardefine:date2_m|{{CURRENTMONTH}}}}{{#vardefine:date2_d|{{CURRENTDAY}}}} }}{{#ifexpr: {{#var:date2_m}} > {{month|{{{1}}}}}
 
| {{#expr:{{#var:date2_y}}-{{year|{{{1}}}}}}}
 
| {{#expr:{{#var:date2_y}}-{{year|{{{1}}}}}}}
 
}}{{#ifexpr: {{#var:date2_m}} < {{month|{{{1}}}}}
 
}}{{#ifexpr: {{#var:date2_m}} < {{month|{{{1}}}}}

Revision as of 02:35, 29 July 2015

Convert a date in the format YYYY-MM-DD to an age in years (based on the current date).

Usage

{{age|1991-06-23}}

returns

33

Optional parameter

Add a second date to calculate the age on that date.

{{age|1991-06-23|1999-09-09}}

returns

8