Hi Simon,

> The question is what the function should do??

Convert a timestamp into a date time format (and then later into a readable 
string).

Thanks for pointing out the casting issue; however, I tried passing it as a 
string and it does not work either.

What would you recommend?

Thanks!

Enrico


--
Enrico Daga, PhD

www.enridaga.net<http://www.enridaga.net/> | @enridaga

SPARQL Anything http://sparql-anything.cc<http://sparql-anything.cc/>
Polifonia http://polifonia-project.eu<http://polifonia-project.eu/>
SPICE http://spice-h2020.eu<http://spice-h2020.eu/>
Open Knowledge Graph http://data.open.ac.uk<http://data.open.ac.uk/>

Senior Research Fellow, Knowledge Media Institute, STEM Faculty
The Open University
Level 4 Berrill Building, Walton Hall, Milton Keynes, MK7 6AA
Direct: +44 (0) 1908 654887
________________________________
From: Simon Bin <[email protected]>
Sent: 18 April 2023 11:43
To: [email protected] <[email protected]>
Subject: Re: XSD date functions broken?

The question is what the function should do??

if you look here: 
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.w3.org%2FTR%2Fsparql11-query%2F%23FunctionMapping&data=05%7C01%7Cenrico.daga%40open.ac.uk%7C8afbac578cf644e8ba0808db3ff9c74a%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174114243585920%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=DEaRRBUhUobpuseI8EwQGbA1ABo7M9XRj9taVmPpj6M%3D&reserved=0<https://www.w3.org/TR/sparql11-query/#FunctionMapping>

it is "N"ot allowed to cast from int to dateTime

On Tue, 2023-04-18 at 10:19 +0000, Enrico.Daga wrote:
> Hi,
>
> I need help using XSD date/time functions, I tried versions 4.2.0 and
> 4.7.0 and both don't seem to work.
>
> Considering this Java code:
>
>
> Dataset kb = DatasetFactory.createGeneral();
> Query q = QueryFactory.create(q);
> result = QueryExecutionFactory.create(q, kb).execSelect();
>
> The following throws an NPE (no results)
>
>
> String q = "\n" +
>         "PREFIX xsd: 
> <https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema%23&data=05%7C01%7Cenrico.daga%40open.ac.uk%7C8afbac578cf644e8ba0808db3ff9c74a%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174114243585920%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=3%2BRsVgMKF8vR2T5a6SkwfKCYLDpn3LVgj4iH2vX%2Fv64%3D&reserved=0<http://www.w3.org/2001/XMLSchema#>>"
>  +
>         "SELECT ?date WHERE { BIND(xsd:dateTime (1649185973) AS ?date
> ) }";
>
> ...
> System.err.println(result.next().get("date").toString());
>
> While the cast to int works fine:
>
>
> String q = "\n" +
>         "PREFIX xsd: 
> <https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema%23&data=05%7C01%7Cenrico.daga%40open.ac.uk%7C8afbac578cf644e8ba0808db3ff9c74a%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174114243585920%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=3%2BRsVgMKF8vR2T5a6SkwfKCYLDpn3LVgj4iH2vX%2Fv64%3D&reserved=0<http://www.w3.org/2001/XMLSchema#>>"
>  +
>         "SELECT ?date WHERE { BIND(xsd:int (1649185973) AS ?date )
> }";
> System.err.println(executeARQ(q).next().get("date").toString());
>
> 1649185973^^https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema%23int&data=05%7C01%7Cenrico.daga%40open.ac.uk%7C8afbac578cf644e8ba0808db3ff9c74a%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174114243585920%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=82aUfvHAyPRbCeKNeJEQ0QQtiNKNKnr3N3Afw8w0v70%3D&reserved=0
>
> Am I missing anything?
>
> Best,
>
> Enrico
>
> --
> Enrico Daga, PhD
>
> https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.enridaga.net%2F&data=05%7C01%7Cenrico.daga%40open.ac.uk%7C8afbac578cf644e8ba0808db3ff9c74a%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174114243585920%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=2l7urXsu9EwIB59M3fA1epW9mkCZfMc19gAaZ%2FLC%2BJE%3D&reserved=0<https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.enridaga.net%2F&data=05%7C01%7Cenrico.daga%40open.ac.uk%7C8afbac578cf644e8ba0808db3ff9c74a%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174114243585920%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=2l7urXsu9EwIB59M3fA1epW9mkCZfMc19gAaZ%2FLC%2BJE%3D&reserved=0><http://www.enridaga.net/>
>  | @enridaga
>
> SPARQL Anything 
> https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fsparql-anything.cc%2F&data=05%7C01%7Cenrico.daga%40open.ac.uk%7C8afbac578cf644e8ba0808db3ff9c74a%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174114243585920%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=3dbOsh39XbtPv5dG7%2FUCVbin0LwolO90bUPawiUSsdM%3D&reserved=0<http://sparql-anything.cc/>
> Polifonia 
> https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fpolifonia-project.eu%2F&data=05%7C01%7Cenrico.daga%40open.ac.uk%7C8afbac578cf644e8ba0808db3ff9c74a%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174114243585920%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=mbj0%2BGFpYTIgyULj%2Fub9RDtZI8gsZ2FA7mb3zhhi4%2BM%3D&reserved=0<http://polifonia-project.eu/>
> SPICE 
> https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fspice-h2020.eu%2F&data=05%7C01%7Cenrico.daga%40open.ac.uk%7C8afbac578cf644e8ba0808db3ff9c74a%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174114243742126%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=8MTl8oUmQ7g1FbR32a3LKNqQ9c0upxGaCe24k8ozV%2Fc%3D&reserved=0<http://spice-h2020.eu/>
> Open Knowledge Graph http://data.open.ac.uk<http://data.open.ac.uk/>
>
> Senior Research Fellow, Knowledge Media Institute, STEM Faculty
> The Open University
> Level 4 Berrill Building, Walton Hall, Milton Keynes, MK7 6AA
> Direct: +44 (0) 1908 654887
> -- The Open University is incorporated by Royal Charter (RC 000391),
> an exempt charity in England & Wales and a charity registered in
> Scotland (SC 038302). The Open University is authorised and regulated
> by the Financial Conduct Authority in relation to its secondary
> activity of credit broking.

-- The Open University is incorporated by Royal Charter (RC 000391), an exempt 
charity in England & Wales and a charity registered in Scotland (SC 038302). 
The Open University is authorised and regulated by the Financial Conduct 
Authority in relation to its secondary activity of credit broking.

Reply via email to