0

So let's say I have an Infobox template in Wikipedia that retrieves a company foundation date from Wikidata. It contains the following code:

|label7 = Year founded
|text7 = {{wikidata|p571|{{{founded|}}}}}

My problem is that what's retrieved is formatted as 31 January 2010 and it looks weird next to "Year founded' since it is not a year but the whole date. Of course I could rename the label from "Year founded" to "Date founded" and voila, problem solved, right? But I do want to just get the year from Wikidata, not the whole date.

What would be the code for this? I imagine something like {{wikidata|p571[year]|{{{founded|}}}}} or {{wikidata|p571[0]|{{{founded|}}}}} or {{wikidata|p571[YYYY]|{{{founded|}}}}}.

Thanks in advance!

Sergey Snegirev
  • 1,016
  • 1
  • 7
  • 23
  • 1
    There are probably nicer methods but as a last resort you can always use `{{#time}}`. – Tgr Oct 30 '16 at 06:12

2 Answers2

3

This doesn't sound like a programming question, but it looks like you can request a specific date format as the third parameter to wikidata
https://en.wikipedia.org/wiki/Module:Wikidata#Testing_getValue.2C_getRawValue_and_getDateValue

{{#invoke:Wikidata|getDateValue|P569|FETCH_WIKIDATA|y}}
Tom Morris
  • 10,490
  • 32
  • 53
-2

I highly recomend you to filter the year from date using RegularExpression instead of trying to get only the year.

Vishnu Ranganathan
  • 1,277
  • 21
  • 45