Jump to content

Template:Age in days/doc: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Temporaluser (talk | contribs)
See also: replaced template list w/ single template
update to reflect changes since Module:Age used in April 2018‎
 
(15 intermediate revisions by 10 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>&nbsp;||(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>&nbsp;||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>&nbsp;||(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>&nbsp;||(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>&nbsp;||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}}
|}


== See also ==
===Sorting===
By adding {{para|sortable|on}} a sort key will be added to the output for use in sortable tables.

===Formatting===
Three styles of formatting are possible.
:{|
|-
|{{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}}&nbsp;||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}}&nbsp;||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|time ago}}
* {{tl|Duration in days}}
* {{tl|Time ago}}
{{Birth, death and age templates}}
<includeonly><!--
++++ PLEASE ADD CATEGORIES AND INTERWIKIS BELOW THIS LINE, THANK YOU. -->
[[Category:Date mathematics templates|{{PAGENAME}}]]
[[Category:Date-computing templates|{{PAGENAME}}]]


{{Birth, death and age templates|age}}
{{commons|Template:Age in days}}


<includeonly>{{sandbox other||
[[ar:قالب:Age in days]]
<!-- Categories below this line and interwikis at Wikidata -->
[[be-x-old:Шаблён:Тэрмін у днях]]
[[Category:Date mathematics templates|{{PAGENAME}}]]
[[bn:টেমপ্লেট:Age in days]]
[[Category:Date-computing templates|{{PAGENAME}}]]
[[cs:Šablona:Věk ve dnech]]
}}</includeonly>
[[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]]
[[sv:Mall:Dagar från idag]]
[[uk:Шаблон:Age in days]]
[[ur:سانچہ:عمر دنوں میں]]
[[vi:Tiêu bản:Tuổi theo ngày]]
</includeonly>

Latest revision as of 10:04, 13 May 2024

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
  1. ^ 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]