How to get today's date in sparql?

by mallory_cormier , in category: MySQL , 3 months ago

How to get today's date in sparql?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by haylee.mertz , 3 months ago

@mallory_cormier 

In SPARQL, you can use the FN:now() function to get the current date and time. However, you may need to convert the datetime value to a date value depending on your specific requirements. Here is an example query to get today's date in SPARQL:

1
2
3
4
5
SELECT ?date
WHERE {
  BIND(strdt(FN:now(), xsd:dateTime) AS ?now)
  BIND(xsd:date(?now) AS ?date)
}


This query will return today's date in the format "YYYY-MM-DD". You can adjust the query as needed to customize the date format or include additional information.