I use Python and SPARQL to make a scheduled query for a database. I tried to use the python f-string and doc-string to inject today's date in the query, but when I try so, a conflict occurs with SPARQL syntax and the python string.
The better way would be to use SPARQL to get today's date.
In my python file my query looks like this:
query = """
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT * {
VALUES (?currentDateString) {(today)}
FILTER(xsd:date(?dateApplicabilityNode) >= xsd:date(?validDateString) && xsd:date(?dateApplicabilityNode) <= xsd:date(?currentDateString))
}
GROUP BY ...
ORDER BY ...
How to get today's date in the format of "YYYY-MM-DD"?