Template:Age in years, months and days/doc

< Template:Age in years, months and days

This template returns the number of full years, then surplus months, then surplus days between two specified dates. If the second set of parameters is not included, it will return the number of years, months and days between a specified date and today's date. The words "year", "month" and "day" are plural when appropriate.

The years and months are separated by a comma. Since serial commas are optional and use varies, this template does not automatically place a comma after the months. If a serial comma is desired, adding |sc=y to the template invocation will include one.

See Wikipedia:Age calculation templates for more information on using this kind of template.

Syntax

{{Age in years, months and days|year= |month= |day= }} or
{{Age in years, months and days|yyyy|mm|dd|yyyy2|mm2|dd2}}

Examples

{{Age in years, months and days|year=2001|month=1|day=15}} returns "23 years, 11 months and 8 days"
{{Age in years, months and days|2001|01|15|2008|09|05}} returns "7 years, 7 months and 21 days"
{{Age in years, months and days|2016|8|4|2016|9|5}} returns "1 month and 1 day"

Notes

This template can handle an ambiguous start date:

{{Age in years, months and days|year=2010|month=9}} returns "14 years and 2 or 3 months"
{{Age in years, months and days|2009|6||2011|2|21}} returns "1 year and 7 or 8 months"

But it cannot handle an ambiguous end date:

{{Age in years, months and days|2012|11|2|2016|4}} returns "3 years and 4 or 5 months"
{{Age in years, months and days|2012|11|2|2017}} returns "4 or 5 years"

Since the length of a month varies, the number of days to roll over the number of months varies.

{{Age in years, months and days|2007|3|12|2015|6|11}} returns "8 years, 2 months and 30 days"
{{Age in years, months and days|2007|3|12|2015|7|11}} returns "8 years, 3 months and 29 days"

To add a serial comma specify |sc=y.

{{Age in years, months and days|year=2001|month=1|day=15|sc=y}} returns "23 years, 11 months, and 8 days"
{{Age in years, months and days|2001|1|15|2008|9|5|sc=y}} returns "7 years, 7 months, and 21 days"
{{Age in years, months and days|2016|12|9|sc=y}} returns "8 years and 14 days"

TemplateData

This is the TemplateData documentation for the template used by the new VisualEditor.

Age in years, months and days

<templatedata>{ "description": "This template returns the number of full years, surplus months, and surplus days between two specified dates. If the second set of parameters is not included, it will return the number of years, months and days between a specified date and today's date.", "params": {

 "1": {
   "label": "Year ('from' date)",
   "description": "The year of the (first) date",
   "type": "number",
   "required": true,
   "aliases": [ "year" ]
 },
 "2": {
   "label": "Month ('from' date)",
   "description": "Number of the month of the (first) date",
   "type": "number",
   "required": true,
   "aliases": [ "month" ]
 },
 "3": {
   "label": "Day of month ('from' date)",
   "description": "The day of the month of the (first) date",
   "type": "number",
   "required": false,
   "aliases": [ "day" ]
 },
 "4": {
   "label": "Year ('to' date)",
   "description": "The year of the 'to' date, if required",
   "type": "number",
   "default": "the current year",
   "required": false
 },
 "5": {
   "label": "Month ('to' date)",
   "description": "Number of the month of the 'to' date, if required",
   "type": "number",
   "default": "the current month",
   "required": false
 },
 "6": {
   "label": "Day of month ('to' date)",
   "description": "The day of the month of the 'to' date, if required",
   "type": "number",
   "default": "the current day",
   "required": false
 },
 "sc": {
   "label": "Serial comma",
   "description": "Enter 'y' to turn on the serial comma after the months",
   "type": "string/line",
   "default": "none",
   "required": false
 }
}

}</templatedata>

See also


There are a number of templates that you can use to set out a person's birth date or birth year, current age, death date or death year, and age at death. This is especially useful in infoboxes. Using these templates rather than simply inserting dates into articles allow hidden metadata about dates to be put into articles. Web browsers and other types of software can look up the metadata and use them for certain types of displays or searches.

The year, month and day of birth and death dates must be typed in numbers. If a number is smaller than ten, you do not have to type a zero before it (for example, you can type "7" instead of "07").

All the templates

What you should type Example What you will see
{{Birth date|[year of birth]|[month of birth]|[day of birth]}} {{Birth date|1965|8|9}} (1965-08-09)August 9, 1965
{{Birth date and age|[year of birth]|[month of birth]|[day of birth]}} {{Birth date and age|1965|8|9}} (1965-08-09) August 9, 1965 (age 59)
{{Birth year and age|[year of birth]|[optional month of birth, if known]}} {{Birth year and age|1965}} 1965 (age 58–59)
{{Birth year and age|1965|8}} August 1965 (age 59)
{{Death date|[year of death]|[month of death]|[day of death]}} {{Death date|2005|12|25}} December 25, 2005
{{Death date and age|[year of death]|[month of death]|[day of death]|[year of birth]|[month of birth]|[day of birth]}} {{Death date and age|2005|12|25|1965|8|9}} December 25, 2005(2005-12-25) (aged 40)
{{Death year and age|[year of death]|[year of birth]|[optional month of death, if known]}} {{Death year and age|2005|1965}} 2005 (aged 39–40)
{{Death year and age|2005|1965|12}} December 2005 (aged 39–40)

Notes

{{Birth date and age}} and {{Birth year and age}}

In {{Birth date and age}} and {{Birth year and age}}, the person's age is calculated based on the current date.

{{Birth year and age}} and {{Death year and age}}

The templates {{Birth year and age}} and {{Death year and age}} show a person's year of birth or death and his or her approximate (rough) age. The templates are useful when only the year of a person's birth and/or death are known, or if you do not want to state a person's full dates of birth and death for privacy reasons.

The person's age is estimated in the following way:

  • {{Birth year and age}} – let us assume:
  1. that the person in question was born some time in 1969; and
  2. that the present date is 23 December 2024.
If the person was born before 23 December 1969 then he will be 54 years old on 23 December 2024 as he has not had his 55th birthday yet. On the other hand, if he was born exactly on or before 23 December 1969, then he will be 55 years old.
Therefore, the template {{Birth year and age|1969}}
displays his birth year and age as: 1969 (age 54–55)
  • {{Death year and age}} – let us assume:
  1. that the person in question was born some time in 1973; and
  2. that she died some time in 2023.
We can think of two extremes: (1) that the person was born on 31 December 1973 and died on 1 January 2023, in which case she would have been 49 years old at the time of her death as she did not achieve her 50th birthday on 31 December 2023; and (2) that she was born on 1 January 1973 and died on 31 December 2023, in which case she would have been 50 years old at the time of her death as she had her 50th birthday on 1 January 2023.
Therefore, the template {{Death year and age|2023|1973}}
shows her death year and age as: 2023 (aged 49–50)

Templates allowing day to be shown before month

The templates in the table below take an optional parameter "df" (which stands for "date first") – you can choose whether to use it or not. If "df=yes", then the day of the date is shown before the month. This is for articles about people from parts of the world where the day usually comes before the month in a date.

What you should type Example What you will see
{{Birth date|[year of birth]|[month of birth]|[day of birth]|df=yes}} {{Birth date|1965|8|9|df=yes}} (1965-08-09)9 August 1965
{{Birth date and age|[year of birth]|[month of birth]|[day of birth]|df=yes}} {{Birth date and age|1965|8|9|df=yes}} (1965-08-09) 9 August 1965 (age 59)
{{Death date|[year of death]|[month of death]|[day of death]|df=yes}} {{Death date|2005|12|25|df=yes}} 25 December 2005
{{Death date and age|[year of death]|[month of death]|[day of death]|[year of birth]|[month of birth]|[day of birth]|df=yes}} {{Death date and age|2005|12|25|1965|8|9|df=yes}} 25 December 2005(2005-12-25) (aged 40)