Template:Age in days: Difference between revisions
Appearance
Content deleted Content added
mNo edit summary |
Plastikspork (talk | contribs) Unlinking circular redirects: Wikipedia:Templates for discussion/Log/2021 December 25#Template:Date difference closed as redirect (XFDcloser) |
||
(24 intermediate revisions by 15 users not shown) | |||
Line 1: | Line 1: | ||
<includeonly>{{#invoke:age|age_generic|template=age_days}}</includeonly><noinclude>{{documentation}}</noinclude> |
|||
<noinclude> |
|||
This template returns the number of days that have elapsed 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: '''<nowiki>{{Age in days|month1= |day1= |year1= |month2= |day2= | year2=}}</nowiki>''' |
|||
</noinclude><includeonly>{{#expr: |
|||
+ {{Gregorian serial date |
|||
|month = {{{month2|{{CURRENTMONTH}}}}} |
|||
|day = {{{day2|{{CURRENTDAY}}}}} |
|||
|year = {{{year2|{{CURRENTYEAR}}}}} |
|||
}} |
|||
- {{Gregorian serial date |
|||
|month = {{{month1|{{CURRENTMONTH}}}}} |
|||
|day = {{{day1|{{CURRENTDAY}}}}} |
|||
|year = {{{year1|{{CURRENTYEAR}}}}} |
|||
}} |
|||
}}</includeonly> |
|||
<noinclude> |
|||
[[Category:Date math|{{PAGENAME}}]] |
|||
[[Category:Templates using ParserFunctions|{{PAGENAME}}]] |
|||
</noinclude> |
Latest revision as of 16:55, 1 January 2022
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
Full dates
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,221 {{age in days||{{#time:j M Y|+ 15 months}}}}
gives 457
Year, month and day
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 6398 |
Sorting
By adding |sortable=on
a sort key will be added to the output for use in sortable tables.
Formatting
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
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.