3

Like the topic says I want to order values by date. I'm using the code

[[Einspiel_{{{1}}}::{{{2}}}| ]]{{{2}}}

in an template to easily refer a value to a variable. {{{1}}} is the name of my variable and {{{2}}} is the date (dd.mm.yyyy).

As it is possible to give the variable multiple values, I want to get the highest date on another wiki page.

I've tried it with something like this

{{#arraydefine:{{{1}}}_Preisdatum
  |{{#ask:[[Kategorie:Aktualisierungen]]
      |?Einspiel_{{{1}}}=
      |mainlabel=-
      |link=none
      |sort=Einspiel_{{{1}}}
      |order=desc}}
    }}
{{#arrayindex:{{{1}}}_Preisdatum|0 }}

but without success. The problem seems to be that the dates are only ordered by the first digit. If I try to get a descending list, the result is:

  • 11.07.2014
  • 08.07.2014
  • 01.01.2015

instead of

  • 01.01.2015
  • 11.07.2014
  • 08.07.2014

I've read that there is a way to order dates with #SORTKEY but I don't know how to include that in my code since my input should be only the newest date. I hope you guys can help me with that. Thanks in advance.

leo
  • 8,106
  • 7
  • 48
  • 80
  • Sorry, I don't understand; why doesn't `#SORTKEY` work for you? What happens when you try? – leo Nov 10 '14 at 14:40
  • Hello. Like I said _'I've read that there is a way to order dates with `#SORTKEY` but I don't know how to include that in my code since my input should be only the newest date.'_ I've tried to change the sort operation from `sort=Einspiel_{{{1}}}` to `sort=Einspiel_{{{1}}}#SORTKEY` but that hasn't worked. Could you tell me how to add `#SORTKEY` to the code above? – Carsten Brinkmann Nov 10 '14 at 15:05
  • @leo - So do you have an idea? – Carsten Brinkmann Nov 13 '14 at 18:52
  • You will need to add the #SORTout to a printout statement, e.g. `|?Einspiel_{{{1}}}#SORTKEY` – leo Nov 14 '14 at 18:43

2 Answers2

0

I don't know how many properties you have like Einspiel_{{{1}}} but you have to create the related pages (ie Template:Einspiel_One, Template:Einspiel_Two, Template:Einspiel_Three etc).

And in each of them you have to specify the datatype of that property by adding the type of the property with. If you don't, Mediawiki doesn't know that this property is a date, and it won't sort it accordingly.

Example

In Template:Einspiel_One :

This is my first property...
[[Has type::Date]]

In Template:Einspiel_Two :

This is my second property...
[[Has type::Date]]

In Template:Einspiel_Three :

This is my thrid property...
[[Has type::Date]]

And so on...

Thibault
  • 1,566
  • 15
  • 22
0

I think Thibault had a mistake in his answer - there is no sense of creating "Template:...", because properties types are stored in "Property:..." namespace. However, it seems like there is no solution for you, except coding own Result Format

wakalaka
  • 524
  • 4
  • 12