Changes
→See also: *{{tiw|MONTHDIFF2}}
{{Documentation subpage}}
<!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE -->
=== Description ===
'''For dates from 1 January 1970 onward only!'''
This template returns the difference in days (possibly with decimals) between two dates in the Gregorian calendar. The return value is positive if <code>date2</code> comes ''after'' <code>date1</code>, and is negative if <code>date2</code> comes ''before'' <code>date1</code> (i.e. the template computes <code>date2 - date1</code>). This template is identical to {{tl|DATEDIFF}}, except that it requires only that up to two parameters be inputted instead of up to twelve since it makes use of the <code>#time:</code> parser function.
=== Usage ===
If two dates supplied, the template calculates the difference between them, in days. If only one date is supplied, then the supplied date is calculated against the current date. If no dates are supplied, the template calculates the number of days from the start of the [[Julian epoch]] to the current date. If an invalid date is supplied, then the text is returned unaltered.
The inputted dates may be in any format understood by the <code>#time:</code> parser function. E.g., <code>July 18, 2008</code>, <code>18 July 2008</code> and <code>2008-07-18</code> are all valid. Hours, minutes and seconds can likewise be inputted.
This template can be used for dates from 1 January 1970 onward only.
=== Examples ===
{| style="border:solid 1px #808080;"
! style="background:#c0c0c0;" | Code
! style="background:#c0c0c0;" | Output
|-
|<code><nowiki>{{DATEDIFF2|18 July 2008|2008-07-16}}</nowiki></code>
| {{DATEDIFF2|18 July 2008|2008-07-16}}
|-
|<code><nowiki>{{DATEDIFF2|July 16, 2008 8PM|2008-07-18 8:00:00}}</nowiki></code>
| {{DATEDIFF2|July 16, 2008 8PM|2008-07-18 8:00:00}}
|-
|<code><nowiki>{{DATEDIFF2|2008-07-18}}</nowiki></code>
| {{DATEDIFF2|2008-07-18}}
|-
|<code><nowiki>{{DATEDIFF2|{{#time:c}}}}</nowiki></code>
| ''should always equal zero''
|-
|<code><nowiki>{{DATEDIFF2}}</nowiki></code>
| {{DATEDIFF2}}
|-
|<code><nowiki>{{DATEDIFF2|invalid}}</nowiki></code>
| {{DATEDIFF2|invalid}}
|}
=== See also ===
*{{tiw|DATEDIFF}}
*{{tiw|JULIANDAY}} - used internally by this template.
*{{tiw|MONTHDIFF2}}
<includeonly>
<!-- CATEGORIES AND INTERWIKIS HERE, THANKS -->
[[Category:Date-computing templates|{{PAGENAME}}]]
</includeonly>
<!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE -->
=== Description ===
'''For dates from 1 January 1970 onward only!'''
This template returns the difference in days (possibly with decimals) between two dates in the Gregorian calendar. The return value is positive if <code>date2</code> comes ''after'' <code>date1</code>, and is negative if <code>date2</code> comes ''before'' <code>date1</code> (i.e. the template computes <code>date2 - date1</code>). This template is identical to {{tl|DATEDIFF}}, except that it requires only that up to two parameters be inputted instead of up to twelve since it makes use of the <code>#time:</code> parser function.
=== Usage ===
If two dates supplied, the template calculates the difference between them, in days. If only one date is supplied, then the supplied date is calculated against the current date. If no dates are supplied, the template calculates the number of days from the start of the [[Julian epoch]] to the current date. If an invalid date is supplied, then the text is returned unaltered.
The inputted dates may be in any format understood by the <code>#time:</code> parser function. E.g., <code>July 18, 2008</code>, <code>18 July 2008</code> and <code>2008-07-18</code> are all valid. Hours, minutes and seconds can likewise be inputted.
This template can be used for dates from 1 January 1970 onward only.
=== Examples ===
{| style="border:solid 1px #808080;"
! style="background:#c0c0c0;" | Code
! style="background:#c0c0c0;" | Output
|-
|<code><nowiki>{{DATEDIFF2|18 July 2008|2008-07-16}}</nowiki></code>
| {{DATEDIFF2|18 July 2008|2008-07-16}}
|-
|<code><nowiki>{{DATEDIFF2|July 16, 2008 8PM|2008-07-18 8:00:00}}</nowiki></code>
| {{DATEDIFF2|July 16, 2008 8PM|2008-07-18 8:00:00}}
|-
|<code><nowiki>{{DATEDIFF2|2008-07-18}}</nowiki></code>
| {{DATEDIFF2|2008-07-18}}
|-
|<code><nowiki>{{DATEDIFF2|{{#time:c}}}}</nowiki></code>
| ''should always equal zero''
|-
|<code><nowiki>{{DATEDIFF2}}</nowiki></code>
| {{DATEDIFF2}}
|-
|<code><nowiki>{{DATEDIFF2|invalid}}</nowiki></code>
| {{DATEDIFF2|invalid}}
|}
=== See also ===
*{{tiw|DATEDIFF}}
*{{tiw|JULIANDAY}} - used internally by this template.
*{{tiw|MONTHDIFF2}}
<includeonly>
<!-- CATEGORIES AND INTERWIKIS HERE, THANKS -->
[[Category:Date-computing templates|{{PAGENAME}}]]
</includeonly>