How to do a SMW query based on the current year/month/etc.?

Viewed 39

I'd like to perform a SMW query based on current year and month information. The problem: It seems that I need to feed values into the SMW ask section in a non-static way as I cannot hard code these values. How can I do that and perform such a query?

2 Answers

Use {{#time:}} parser function. Date formats that SMW will understand are given here. Below, I used d.m.Y and d xg Y that will definitely work in a wiki in Russian.

Use Unix format (U, the number of seconds since Unix era; use @ to convert it back to date object) for date arithmetics.

Examples (assuming that you have the special property Creation date activated):

<!-- Pages created today -->
{{#ask:
[[Creation date::>={{#time:d.m.Y}}]]
}}

<!-- Pages created yesterday -->
{{#ask:
[[Creation date::>={{#time:d xg Y|@{{#expr:{{#time:U}}-86400}}}}]]
[[Creation date::<{{#time:d xg Y}}]]
}}

Related