Changes

Jump to: navigation, search

Template:AgeMonths

1,297 bytes added, 18:02, 18 April 2017
Created page with "<includeonly>{{#expr: 12 * ( {{{year2 | {{{4 | {{CURRENTYEAR}} }}} }}} - {{{year1 | {{{1 | {{CURRENTYEAR}} }}} }}} ) + ( {{{month2 | {{{5 | {{CURRENTMONTH}} }}..."
<includeonly>{{#expr:
12 * (
{{{year2 | {{{4 | {{CURRENTYEAR}} }}} }}} -
{{{year1 | {{{1 | {{CURRENTYEAR}} }}} }}}
) + (
{{{month2 | {{{5 | {{CURRENTMONTH}} }}} }}} -
{{{month1 | {{{2 | {{CURRENTMONTH}} }}} }}}
) +
{{#ifexpr: {{{day2 | {{{6 | {{CURRENTDAY}} }}} }}} >= {{{day1 | {{{3 | {{CURRENTDAY}} }}} }}}
| 0
| -1
}}
}}</includeonly><noinclude>
==Description==
Compares two dates and returns difference in months.
===Parameters===
<pre>{{AgeMonths
|year1
|month1
|day1

|year2
|month2
|day2
}}</pre>
;year1 (first parameter)
:year to check
;month1 (second parameter)
:month to check
;day1 (third parameter)
:day to check
;year2 (fourth parameter)
:year to compare, current year by default
;month2 (fifth parameter)
:month to compare, current month by default
;day2 (sixth parameter)
:day to compare, current day by default
===Example===
If you want to show how many months have passed since given day (for example) 01-01-1999 use '''<nowiki>{{AgeMonths|1999|1|1}}</nowiki>''': that will show '''{{AgeMonths|1999|1|1}}'''.

If you want to compare two dates (for example 01-01-1999 and 03-10-2010) use: '''<nowiki>{{AgeMonths|1999|1|1|2010|10|3}}</nowiki>''': that will show '''{{AgeMonths|1999|1|1|2010|10|3}}'''.

[[Category:Date templates]]</noinclude>
150
edits

Navigation menu