Discuss Help:Datatype "Date"

From semantic-mediawiki.org

Standard date ? 2010-03-10T07:30:00Z[edit]

2010-03-10T07:30:00Z, I need to insert this format, it's poosible ?

Selecting pages by date[edit]

  • How do I select pages by giving the year of a property of type date? Tomaschwutz 19:50, 12 January 2012 (CET)
One way would be
{{#ask: [[The date::≥1/1/2009]] [[The date::≤31/12/3009]]}}
--Jan "Saruman!" S. 21:24, 12 January 2012 (CET)

Handling of incomplete dates[edit]

The help page says that if only the year is entered, defaults will be used (and no error should occur). I am finding that when a semantic property tag of type date is used in a Semantic form, and an incomplete date is entered in that field, no result is returned--it is requiring not only the year and month, but also the day or else no information will be displayed.

Here is my version information:

MediaWiki 1.18.0
PHP 5.2.17 (cgi-fcgi)
MySQL 5.1.56
Semantic Forms (Version 2.3.2)
Semantic MediaWiki (Version 1.7)

Here is the relevant wikicode from the infobox template:

{{#if: {{{birthdate|}}}|! Birthdate {{!}} [[Birthdate::{{{birthdate|}}}]]}}

Here is the relevant wikicode from the form:

! Birth date: | {{{field|birthdate}}}

Here is the wikicode from Property:Birthdate

This property is a [[has type::date]] representing the birth date of a user.

What I would like to have happen is that if a user enters only a year in the form, then that year shows up in the infobox. If a month and year are entered, then the infobox displays that, and so on. Is there something I need to change to allow this?

Thanks in advance.--Lost Student 03:57, 26 January 2012 (CET)

Selecting pages by anniversary[edit]

How do I select pages by giving the day and month of a property of type date? I have pages with a property "birthday" or "foundation day", I want to select them by anniversary and if possible give their age in years. --Wouter Rademaker 13:48, 7 April 2012 (CEST)

See https://github.com/SemanticMediaWiki/SemanticMediaWiki/issues/4654

Contents

Thread titleRepliesLast modified
sorting dates in tables101:44, 11 May 2019
Dates without years210:54, 26 January 2016
How to change date format in property page?113:51, 3 January 2016
SMW displaying dates in UTC015:40, 20 June 2014
Request - new date formats219:57, 6 May 2014
How can I sort a table for current's date is displayed?005:15, 26 March 2014
Enabling multinational date formats122:11, 1 February 2013

sorting dates in tables

I don't quite get the example regarding sorting dates in a table. Who would want an extra table with the sortkey displayed?

{{#ask:
 [[Modification date::+]]
 |?Modification date
 |?Modification date#SORTKEY
}}

I have seen SMW doing it wrong, but in sandbox everything works fine: https://sandbox.semantic-mediawiki.org/wiki/Date_sorting_in_tables

So why would I need #SORTKEY and how would I use it?

07:41, 9 May 2019

> I don't quite get the example regarding sorting dates in a table. Who would want an extra table with the sortkey displayed?

I don't know either but the function is available at least since 1.7.1 [0] and returns the JD of the date which is also used internally to sort dates.

> I have seen SMW doing it wrong

Where and in which context?

> So why would I need #SORTKEY and how would I use it?

[0] is the PR that introduced the output format and notes "new output format "sortkey" to help people who want to handcraft sortable tables containing date values".

[0] https://github.com/SemanticMediaWiki/SemanticMediaWiki/commit/34645e5ecf8044894541445305113b05f3cc0cbd

Cheers

01:44, 11 May 2019
 

Dates without years

Not sure if this is true by design but there's no error message if a value of type 'Date' consists of just a day and a month, for instance "2 February" - a query for "2 February" gives appropriate results. Because such incomplete dates cannot be interpreted as points in time, as the page points out, I was surprised to see this behaviour, but if it is a bug, I'd welcome it anyway: it lets you add annual events without any specific start and end.

(Note also that if you had events on, say, 2 February 1567, 2 February 1785 and 2 February 2014, there's no way of querying for all events that happened on 2 February in whatever year; but adding "2 February" as a value would do the trick).

16:59, 25 January 2016

> type 'Date' consists of just a day and a month, for instance "2 February" - a query for "2 February"

Well, it is conceivable that a user would interpret "2 February" as something like 2nd of Feb with NO YEAR but the system understands the input as 0002 Year + 2nd Month hence the point in time is fixed by (Calendar model 2 (JL)/2 (Year) / 2(Month)) without a specific day or time.

From that perspective, Year + Month are allowed to exists without having to specify a day or time.

09:22, 26 January 2016

Oh I see, that makes sense and it explains why the date is listed as "February 2" in Special:Browse, if I recall correctly, and why "33 February" is permitted as well.

10:54, 26 January 2016
 
 

How to change date format in property page?

I would like to ask whether the date format in the property page could be changed. For example, in the property page of a DateType property, pages using this property in the list are automatically arranged by date. But the date displayed is always in the day-month-year format (e.g. 30 December 2013 23:59:25). I would like to know how to change it into year-month-day format. I have tried to search for solutions in this wiki but it seems that there is no related content.

09:48, 6 February 2014

You can work with the parser function time. In your case this should work: {{#time:Y-m-d|{{{NameOfYourProperty|}}}}}

13:51, 3 January 2016
 

SMW displaying dates in UTC

Hello there,

SMW is displaying dates in Creation date and Modification date properties in UTC while wiki itself displays dates in article history pages in my local time, which is annoying. My server clocl is also set up to my local time zone. Any ideas how to fix this problem?

15:40, 20 June 2014

Request - new date formats

Would it be possible to add to SMW two new date formats? That is: BP and b2k. They are widely used in geology and archaeology. The "BP" is acronym to "before present" and is counted in years before 1950 (f.e., year 1900 = 50BP). The "b2k" means "years before year 2000", and is counted analogically: calendar year 1900 = 100b2k.

Of course it is possible to calculate dates from BC notation, but it makes some mess, because the BP and b2k notations are standard in earth sciences.

Thanks in advance,

18:55, 6 May 2014

Feature requests should be made at [0] in order to allow for appropriate tracking and analysis.

[0] https://github.com/SemanticMediaWiki/SemanticMediaWiki/issues

19:36, 6 May 2014

Thank you for pointing this out!

all the best, Darek

19:57, 6 May 2014
 
 

How can I sort a table for current's date is displayed?

I tried putting this:


05:11, 26 March 2014

Enabling multinational date formats

Hi there,

I am looking for a way to enable multiple date formats at once, like e.g. english and german formats. Currently, I can only choose one by setting wgLanguageCode. Do you see a way? Where are the actual definitions stored?

Kind regards and thanks

17:05, 1 February 2013

You can control the output by using the PaserFunctions extension (#time), e.g. [[Has birthdate::{{{birthdate|}}}|{{#time:F j, Y|{{{birthdate}}}}}]] for the English format and [[Hat Geburtsdatum::{{{Geburtsdatum|}}}|{{#time:j. F Y|{{{Geburtsdatum}}}}}]] for the German format.

22:10, 1 February 2013