1

The following wikidata query lists the teams Cristiano Ronaldo played for including start and end dates.

SELECT ?playerLabel ?teamLabel ?start ?end WHERE {
  VALUES ?player {
    wd:Q11571
  }
  ?player p:P54 ?teams.
  ?teams ps:P54 ?team;
    pq:P580 ?start.
  OPTIONAL { ?teams pq:P582 ?end. }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". }
}

Link to query

His end date at Juventus is not a valid date.

Partial Result

playerLabel teamLabel start end
Cristiano Ronaldo Juventus F.C. 10 July 2018 t2136841315

Question: What is the correct way to show items with invalid dates?

2
2

you could add this line: BIND( STR(?end) as ?ended ).

SELECT  ?playerLabel ?teamLabel ?start ?ended  WHERE {
  VALUES ?player {
    wd:Q11571
  }
  ?player p:P54 ?teams.
  ?teams ps:P54 ?team;
    pq:P580 ?start.
  OPTIONAL { 
    ?teams pq:P582 ?end. 
   
    BIND( STR(?end)  as ?ended ).
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". }
}

This will result in this. The dates are now longer but still in ISO8601 format.

playerLabel teamLabel start ended
Cristiano Ronaldo Portugal national under-15 football team 2001-01-01T00:00:00Z 2001-01-01T00:00:00Z
Cristiano Ronaldo Portugal national under-17 football team 2001-01-01T00:00:00Z 2002-01-01T00:00:00Z
Cristiano Ronaldo Sporting CP 2002-01-01T00:00:00Z 2003-01-01T00:00:00Z
Cristiano Ronaldo Portugal national under-21 football team 2002-01-01T00:00:00Z 2003-01-01T00:00:00Z
Cristiano Ronaldo Portugal national association football team 2003-01-01T00:00:00Z
Cristiano Ronaldo Portugal national under-20 football team 2003-01-01T00:00:00Z 2003-01-01T00:00:00Z
Cristiano Ronaldo Manchester United F.C. 2003-01-01T00:00:00Z 2009-07-01T00:00:00Z
Cristiano Ronaldo Portugal Olympic football team 2004-01-01T00:00:00Z 2004-01-01T00:00:00Z
Cristiano Ronaldo Real Madrid CF 2009-07-01T00:00:00Z 2018-07-10T00:00:00Z
Cristiano Ronaldo Juventus F.C. 2018-07-10T00:00:00Z
1
  • That is good to know. That field doesn't convert to string. Is there a way to filter on that null value? I'm looking for errors in the data.
    – Wainage
    Dec 30 '20 at 14:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.