Template:Age2/doc: Difference between revisions
Appearance
m remove unnecessary template references |
m remove unnecessary references |
||
| Line 28: | Line 28: | ||
* <code><nowiki>{{Age2|2000|7|31|2010|7|}}</nowiki></code> returns "{{Age2|2000|7|31|2010|7|}}" (if day2 = 31 it'll be 10, otherwise it'll be 9) | * <code><nowiki>{{Age2|2000|7|31|2010|7|}}</nowiki></code> returns "{{Age2|2000|7|31|2010|7|}}" (if day2 = 31 it'll be 10, otherwise it'll be 9) | ||
* <code><nowiki>{{Age2|2000|2|29|2010|2|}}</nowiki></code> returns "{{Age2|2000|2|29|2010|2|}}" (it can only be 9) | * <code><nowiki>{{Age2|2000|2|29|2010|2|}}</nowiki></code> returns "{{Age2|2000|2|29|2010|2|}}" (it can only be 9) | ||
* <code><nowiki>{{Age2|2000|2||2010|2|28}}</nowiki></code> returns "{{Age2|2000|2||2010|2|28}}" (if day1 = 29 (2000 is a | * <code><nowiki>{{Age2|2000|2||2010|2|28}}</nowiki></code> returns "{{Age2|2000|2||2010|2|28}}" (if day1 = 29 (2000 is a leap year) it'll be 9, otherwise it'll be 10) | ||
===Note=== | ===Note=== | ||
Latest revision as of 13:17, 5 October 2025
This is a template documentation subpage for Template:Age2.
It contains usage information, categories, and other content that is not part of the original template page.
It contains usage information, categories, and other content that is not part of the original template page.
This template returns the number(s) of full years between two specified dates. It may return one number (e.g. "50") or two possible numbers (e.g. "50-51") of full years, depending on the given information of the two dates.
The template is especially designed for situations where the day, or day and month, of the two dates is unknown.
Usage
{{Age2|<year1(yyyy)>|<month1(mm)>|<day1(dd)>|<year2(yyyy)>|<month2(mm)>|<day2(dd)>|sortable=}}
year1,month1,day1are for the starting dateyear2,month2,day2are for the ending dateyear1andyear2are requiredmonth1,month2,day1,day2are optional, if one or some of them is unknown, it may be omitted, or left blank, or filled in "0", "00", like:{{Age2|2000|7|23|2010||}}or{{Age2|2000|7|23|2010}};{{Age2|2000|0|0|2010|7|14}}or{{Age2|2000|||2010|7|14}}- When entering dates before the Common Era, use astronomical year numbering: 1 BC is represented by 0, 2 BC by -1, 3 BC by -2, etc. For example, to calculate Augustus (23 September 63 BC – 19 August 14 AD)'s age:
{{Age2|-62|9|23|14|8|19}}returns "75"
note sortable relies on modules so don't use it
- "sortable", optional, fill in "yes" to add a hidden key, making it sort correctly in sortable tables. See original wikipedia template for how it works if start using modules
Examples
{{Age2|2000|7|23|2010|7|14}}returns "9"{{Age2|2000|7|23|2010|7|}}returns "9-10" (if day2 >= 23 it'll be 10, otherwise it'll be 9){{Age2|2000|6|23|2010|7|}}returns "10" (it can only be 10){{Age2|2000|8|23|2010|7|}}returns "9" (it can only be 9){{Age2|2000|7||2010|7|}}returns "9-10" (10 and 9 are both possible)
When one of the dates is the first or last day of the month or year:
{{Age2|2000|1|1|2010||}}returns "10" (it can only be 10, even if month2 and day2 are both 1){{Age2|2000|7||2010|7|31}}returns "10" (it can only be 10, even if day1 = 31){{Age2|2000|7|31|2010|7|}}returns "9-10" (if day2 = 31 it'll be 10, otherwise it'll be 9){{Age2|2000|2|29|2010|2|}}returns "9" (it can only be 9){{Age2|2000|2||2010|2|28}}returns "9-10" (if day1 = 29 (2000 is a leap year) it'll be 9, otherwise it'll be 10)
Note
This template does not check for incorrect input:
{{age2|1980|7|14|1993|6|233}}returns "12" (surplus days do not count as extra months){{age2|1980|7|14|1993|88|14}}returns "13" (surplus months do not count as extra years)