Jump to content

Template:Age in days/doc: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
m Reverted edits by 79.167.11.160 to last version by Yakiv Gluck
update to reflect changes since Module:Age used in April 2018‎
 
(37 intermediate revisions by 30 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:
To use, type:
:<nowiki>{{age in days|month1= |day1= |year1= |month2= |day2= | year2=}},</nowiki> or with unnames parameters:
:{|
:<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|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:
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|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====
To use, type:
:{|
|-
|<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:
{|
|-
|<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}}
|}

===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==
==See also==
* [[Wikipedia:Age calculation templates]]
*{{tl|age}} — Age in years
*{{tl|age in years and days}} — Age in years and days
* {{tl|Duration in days}}
*{{tl|birth date and age}}
* {{tl|Time ago}}

*{{tl|Age in days nts}} — Like this template, but will sort correctly in sortable tables.
*[[Wikipedia:Age calculation templates]]
{{Birth, death and age templates|age}}


<includeonly><!--
<includeonly>{{sandbox other||
<!-- Categories below this line and interwikis at Wikidata -->
++++ PLEASE ADD CATEGORIES AND INTERWIKIS BELOW THIS LINE, THANK YOU. -->
[[Category:Date mathematics templates|{{PAGENAME}}]]
[[Category:Date mathematics templates|{{PAGENAME}}]]
[[Category:Date-computing templates|{{PAGENAME}}]]
[[be-x-old:Шаблён:Тэрмін у днях]]
}}</includeonly>
[[cs:Šablona:Věk ve dnech]]
[[de:Vorlage:Tagesdifferenz]]
[[dsb:Pśedłoga:Diferenca pó dnjach]]
[[eo:Ŝablono:Tagdiferenco]]
[[hsb:Předłoha:Diferenca po dnjach]]
[[is:Snið:Aldur í dögum]]
[[nl:Sjabloon:Aantal dagen]]
[[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 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]