Template:Age in days/doc: Difference between revisions
Appearance
Content deleted Content added
No edit summary |
update to reflect changes since Module:Age used in April 2018 |
||
(22 intermediate revisions by 17 users not shown) | |||
Line 1: | Line 1: | ||
{{Documentation subpage}} |
{{Documentation subpage}} |
||
{{High-use|2348}} |
|||
<!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE. --> |
|||
{{Lua|Module:Age}} |
|||
{{Template shortcuts|aid}} |
|||
This template returns the number of days between two dates. Dates may be input either as full dates or as year, month and day. |
|||
==Usage== |
==Usage== |
||
====Full dates==== |
|||
This template returns the number of days between two dates. If the second set of parameters is not included it will automatically calculate the days between a given date and today. |
|||
To use, type: |
|||
:{| |
|||
|- |
|||
|<code><nowiki>{{age in days|date1|date2}}</nowiki></code> ||(number of days between dates 1 and 2), |
|||
|- |
|||
|<code><nowiki>{{age in days|date1}}</nowiki></code> ||(number of days since date 1) or |
|||
|- |
|||
|<code><nowiki>{{age in days||date2}}</nowiki></code> ||(number of days until date 2) |
|||
|} |
|||
Examples: |
|||
To use, type: |
|||
:{| |
|||
:<nowiki>{{age in days|month1= |day1= |year1= |month2= |day2= | year2=}}</nowiki> |
|||
|- |
|||
|<code><nowiki>{{age in days|19 Aug 2008|4 Sep 2010}}</nowiki></code> ||gives {{age in days|19 Aug 2008|4 Sep 2010}} |
|||
|- |
|||
|<code><nowiki>{{age in days|27 May 2002}}</nowiki></code> ||gives {{age in days|27 May 2002}} |
|||
|- |
|||
|<code><nowiki>{{age in days||{{#time:j M Y|+ 15 months}}}}</nowiki></code> ||gives {{age in days||{{#time:j M Y|+ 15 months}}}} |
|||
|} |
|||
====Year, month and day==== |
|||
Or with unnamed parameters: |
|||
To use, type: |
|||
:<nowiki>{{age in days|year1|month1|day1|year2|month2|day2}}</nowiki> or |
|||
:{| |
|||
:<nowiki>{{age in days|year1|month1|day1}}</nowiki> |
|||
|- |
|||
|<code><nowiki>{{age in days|year1|month1|day1|year2|month2|day2}}</nowiki></code> ||(number of days between dates 1 and 2), |
|||
|- |
|||
|<code><nowiki>{{age in days|year1|month1|day1}}</nowiki></code> ||(number of days since date 1) or |
|||
|- |
|||
|<code><nowiki>{{age in days||||year2|month2|day2}}</nowiki></code> ||(number of day until date 2) |
|||
|} |
|||
Or with named parameters: |
|||
:{| |
|||
|- |
|||
|<code><nowiki>{{age in days|month1= |day1= |year1= |month2= |day2= | year2= }}</nowiki></code> ||(number of days between dates 1 and 2), |
|||
|- |
|||
|<code><nowiki>{{age in days|month1= |day1= |year1= }}</nowiki></code> ||(number of days since date 1) or |
|||
|- |
|||
|<code><nowiki>{{age in days|month2= |day2= | year2= }}</nowiki></code> ||(number of day until date 2) |
|||
|} |
|||
Examples: |
Examples: |
||
{| |
|||
*<nowiki>{{age in days|2007|5|24|2008|4|23}}</nowiki> gives {{age in days|2007|5|24|2008|4|23}} |
|||
|- |
|||
*<nowiki>{{age in days|2007|5|24}}</nowiki> gives {{age in days|2007|5|24}} |
|||
|<code><nowiki>{{age in days|2007|5|24|2008|4|23}}</nowiki></code> ||gives {{age in days|2007|5|24|2008|4|23}} |
|||
|- |
|||
|<code><nowiki>{{age in days|2007|5|24}}</nowiki></code> ||gives {{age in days|2007|5|24}} |
|||
|} |
|||
== |
===Sorting=== |
||
By adding {{para|sortable|on}} a sort key will be added to the output for use in sortable tables. |
|||
* {{tl|age}} — Age in years |
|||
* {{tl|age in years and days}} — Age in years and days |
|||
===Formatting=== |
|||
* {{tl|birth date and age}} |
|||
Three styles of formatting are possible. |
|||
* {{tl|Age in days nts}} — Like this template, but will sort correctly in sortable tables. |
|||
:{| |
|||
* {{tl|time ago}} |
|||
|- |
|||
|{{para|format|raw}} ||gives unformatted numbers with hyphens as minus signs<ref>Negative days will occur if the first date is after the second.</ref> (for use in further calculations). |
|||
|- |
|||
|{{para|format|commas}} ||gives numbers formatted with commas and true minus signs. |
|||
|} |
|||
For reasons of retrospective compatibility, the default when inputting dates as year, month and day is {{para|format|raw}}; however when inputting dates in full it is {{para|format|commas}}. |
|||
:Note |
|||
{{Reflist}} |
|||
===Showing the unit=== |
|||
The default is not to show units. To show the unit ("day", days" or "d") use {{para|show unit}}. |
|||
:{| |
|||
|- |
|||
|{{para|show unit|abbr}} ||adds "d" after the number of days. |
|||
|- |
|||
|{{para|show unit|full}} ||adds "day" or "days" after the number of days as appropriate. |
|||
|} |
|||
==See also== |
|||
* [[Wikipedia:Age calculation templates]] |
* [[Wikipedia:Age calculation templates]] |
||
* {{tl|Duration in days}} |
|||
* {{tl|Time ago}} |
|||
{{Birth, death and age templates|age}} |
|||
<includeonly><!-- |
|||
++++ PLEASE ADD CATEGORIES AND INTERWIKIS BELOW THIS LINE, THANK YOU. --> |
|||
<includeonly>{{sandbox other|| |
|||
<!-- Categories below this line and interwikis at Wikidata --> |
|||
[[Category:Date mathematics templates|{{PAGENAME}}]] |
[[Category:Date mathematics templates|{{PAGENAME}}]] |
||
[[Category:Date-computing templates|{{PAGENAME}}]] |
[[Category:Date-computing templates|{{PAGENAME}}]] |
||
}}</includeonly> |
|||
[[ar:قالب:Age in days]] |
|||
[[be-x-old:Шаблён:Тэрмін у днях]] |
|||
[[cs:Šablona:Věk ve dnech]] |
|||
[[de:Vorlage:Tagesdifferenz]] |
|||
[[es:Plantilla:Edad en días]] |
|||
[[dsb:Pśedłoga:Diferenca pó dnjach]] |
|||
[[eo:Ŝablono:Tagdiferenco]] |
|||
[[fa:الگو:سن به روز]] |
|||
[[fr:Modèle:Age en jours]] |
|||
[[hsb:Předłoha:Diferenca po dnjach]] |
|||
[[is:Snið:Aldur í dögum]] |
|||
[[ja:Template:Age in days]] |
|||
[[ko:틀:날짜세기]] |
|||
[[hu:Sablon:Age in days]] |
|||
[[nl:Sjabloon:Aantal dagen]] |
|||
[[pt:Predefinição:Idade em dias]] |
|||
[[ru:Шаблон:Days between]] |
|||
[[uk:Шаблон:Age in days]] |
|||
[[vi:Tiêu bản:Tuổi theo ngày]] |
|||
</includeonly> |
Latest revision as of 10:04, 13 May 2024
This is a documentation subpage for Template:Age in days. It may contain usage information, categories and other content that is not part of the original template page. |
This template is used on approximately 4,900 pages and changes may be widely noticed. Test changes in the template's /sandbox or /testcases subpages, or in your own user subpage. Consider discussing changes on the talk page before implementing them. |
This template uses Lua: |
This template returns the number of days between two dates. Dates may be input either as full dates or as year, month and day.
Usage
[edit]Full dates
[edit]To use, type:
{{age in days|date1|date2}}
(number of days between dates 1 and 2), {{age in days|date1}}
(number of days since date 1) or {{age in days||date2}}
(number of days until date 2)
Examples:
{{age in days|19 Aug 2008|4 Sep 2010}}
gives 746 {{age in days|27 May 2002}}
gives 8,222 {{age in days||{{#time:j M Y|+ 15 months}}}}
gives 457
Year, month and day
[edit]To use, type:
{{age in days|year1|month1|day1|year2|month2|day2}}
(number of days between dates 1 and 2), {{age in days|year1|month1|day1}}
(number of days since date 1) or {{age in days||||year2|month2|day2}}
(number of day until date 2)
Or with named parameters:
{{age in days|month1= |day1= |year1= |month2= |day2= | year2= }}
(number of days between dates 1 and 2), {{age in days|month1= |day1= |year1= }}
(number of days since date 1) or {{age in days|month2= |day2= | year2= }}
(number of day until date 2)
Examples:
{{age in days|2007|5|24|2008|4|23}} |
gives 335 |
{{age in days|2007|5|24}} |
gives 6399 |
Sorting
[edit]By adding |sortable=on
a sort key will be added to the output for use in sortable tables.
Formatting
[edit]Three styles of formatting are possible.
|format=raw
gives unformatted numbers with hyphens as minus signs[1] (for use in further calculations). |format=commas
gives numbers formatted with commas and true minus signs.
For reasons of retrospective compatibility, the default when inputting dates as year, month and day is |format=raw
; however when inputting dates in full it is |format=commas
.
- Note
- ^ Negative days will occur if the first date is after the second.
Showing the unit
[edit]The default is not to show units. To show the unit ("day", days" or "d") use |show unit=
.
|show unit=abbr
adds "d" after the number of days. |show unit=full
adds "day" or "days" after the number of days as appropriate.
See also
[edit]