Hi Martynas, I think you are right; my mistake. But how would you handle the case of converting a Unix timestamp into a readable date in SPARQL?
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: Martynas Jusevičius <[email protected]> Sent: 18 April 2023 14:04 To: [email protected] <[email protected]> Subject: Re: XSD date functions broken? Neither 1649185973 nor “1649185973” is a valid xsd:date value. Isn’t that the issue? On Tue, 18 Apr 2023 at 14.00, Enrico.Daga <[email protected]> wrote: > 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 > > https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.enridaga.net%2F&data=05%7C01%7Cenrico.daga%40open.ac.uk%7C28d24f570de747ce9c0e08db400d7a51%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174198852403818%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=p6HEWVpg5eSanObasQx%2BPP2ooCF7mysQNdEcGrtkcic%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%7C28d24f570de747ce9c0e08db400d7a51%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174198852403818%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=p6HEWVpg5eSanObasQx%2BPP2ooCF7mysQNdEcGrtkcic%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%7C28d24f570de747ce9c0e08db400d7a51%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174198852403818%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=m08QOKmLG%2B%2Fb8stsndWMq989GXfT8oZ009wt5T4GNok%3D&reserved=0<https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fsparql-anything.cc%2F&data=05%7C01%7Cenrico.daga%40open.ac.uk%7C28d24f570de747ce9c0e08db400d7a51%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174198852403818%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=m08QOKmLG%2B%2Fb8stsndWMq989GXfT8oZ009wt5T4GNok%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%7C28d24f570de747ce9c0e08db400d7a51%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174198852403818%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=NFdA%2FYtjXi0lFLkl2S9CB9r4dzoTQxFl2ddx2O32rqc%3D&reserved=0<https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fpolifonia-project.eu%2F&data=05%7C01%7Cenrico.daga%40open.ac.uk%7C28d24f570de747ce9c0e08db400d7a51%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174198852403818%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=NFdA%2FYtjXi0lFLkl2S9CB9r4dzoTQxFl2ddx2O32rqc%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%7C28d24f570de747ce9c0e08db400d7a51%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174198852403818%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=LuXIx0F8FycPuLt5PIVI74JxZdvbT32%2FS0roiqYSJpM%3D&reserved=0<https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fspice-h2020.eu%2F&data=05%7C01%7Cenrico.daga%40open.ac.uk%7C28d24f570de747ce9c0e08db400d7a51%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174198852403818%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=LuXIx0F8FycPuLt5PIVI74JxZdvbT32%2FS0roiqYSJpM%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 > ________________________________ > 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%7C28d24f570de747ce9c0e08db400d7a51%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174198852560045%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=xYgGQF9kRhTJuj%2FlneMKp7qs0Fohvg4s1iZVQn4YEtA%3D&reserved=0<https://www.w3.org/TR/sparql11-query/#FunctionMapping> > <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%7C28d24f570de747ce9c0e08db400d7a51%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174198852560045%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=xYgGQF9kRhTJuj%2FlneMKp7qs0Fohvg4s1iZVQn4YEtA%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%7C28d24f570de747ce9c0e08db400d7a51%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174198852560045%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=KU53dAMha4w0IBVbonaLM6z54t873Q2mRfJ0Oriju%2F8%3D&reserved=0<http://www.w3.org/2001/XMLSchema#> > <https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema%23&data=05%7C01%7Cenrico.daga%40open.ac.uk%7C28d24f570de747ce9c0e08db400d7a51%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174198852560045%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=KU53dAMha4w0IBVbonaLM6z54t873Q2mRfJ0Oriju%2F8%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%7C28d24f570de747ce9c0e08db400d7a51%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174198852560045%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=KU53dAMha4w0IBVbonaLM6z54t873Q2mRfJ0Oriju%2F8%3D&reserved=0<http://www.w3.org/2001/XMLSchema#> > <https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema%23&data=05%7C01%7Cenrico.daga%40open.ac.uk%7C28d24f570de747ce9c0e08db400d7a51%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174198852560045%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=KU53dAMha4w0IBVbonaLM6z54t873Q2mRfJ0Oriju%2F8%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%7C28d24f570de747ce9c0e08db400d7a51%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174198852560045%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=EbC%2FNLA72GNqxxEnk9%2B%2FyWZoynFpE6Pgh%2BlHbBj%2FEpo%3D&reserved=0<http://www.w3.org/2001/XMLSchema#int> > > > > 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%7C28d24f570de747ce9c0e08db400d7a51%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174198852560045%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=RFw6P133VXtZIyXvXC1bfCyB%2BoGXp2AtnwDqN%2FYxlLU%3D&reserved=0<http://www.enridaga.net/> > < > https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.enridaga.net%2F&data=05%7C01%7Cenrico.daga%40open.ac.uk%7C28d24f570de747ce9c0e08db400d7a51%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174198852560045%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=RFw6P133VXtZIyXvXC1bfCyB%2BoGXp2AtnwDqN%2FYxlLU%3D&reserved=0<http://www.enridaga.net/> > ><https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.enridaga.net%2F&data=05%7C01%7Cenrico.daga%40open.ac.uk%7C28d24f570de747ce9c0e08db400d7a51%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174198852560045%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=RFw6P133VXtZIyXvXC1bfCyB%2BoGXp2AtnwDqN%2FYxlLU%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%7C28d24f570de747ce9c0e08db400d7a51%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174198852560045%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=2VcJBiRsGJoXnzq2UJWGuu3F8%2BGfKSe8R56wfWdRWTg%3D&reserved=0<http://sparql-anything.cc/> > <https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fsparql-anything.cc%2F&data=05%7C01%7Cenrico.daga%40open.ac.uk%7C28d24f570de747ce9c0e08db400d7a51%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174198852560045%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=2VcJBiRsGJoXnzq2UJWGuu3F8%2BGfKSe8R56wfWdRWTg%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%7C28d24f570de747ce9c0e08db400d7a51%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174198852560045%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=XkjiC1F6Cskrw3W1VIICCClRPN9GRPnp2Dwl5KowYG0%3D&reserved=0<http://polifonia-project.eu/> > <https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fpolifonia-project.eu%2F&data=05%7C01%7Cenrico.daga%40open.ac.uk%7C28d24f570de747ce9c0e08db400d7a51%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174198852560045%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=XkjiC1F6Cskrw3W1VIICCClRPN9GRPnp2Dwl5KowYG0%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%7C28d24f570de747ce9c0e08db400d7a51%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174198852560045%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=fJTp%2ByPcXVQbDgCjVTpf89jY188u0M3r48L3%2B1IAMcA%3D&reserved=0<http://spice-h2020.eu/> > <https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fspice-h2020.eu%2F&data=05%7C01%7Cenrico.daga%40open.ac.uk%7C28d24f570de747ce9c0e08db400d7a51%7C0e2ed45596af4100bed3a8e5fd981685%7C0%7C0%7C638174198852560045%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=fJTp%2ByPcXVQbDgCjVTpf89jY188u0M3r48L3%2B1IAMcA%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. > -- 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.
