Global variable ${__to📅YYYY-MM-DD} does not work

  • What Grafana version and what operating system are you using?
    Docker image grafana/grafana-oss:9.5.16. Also tried on

  • What are you trying to achieve?
    When querying loki datasource, I wanted return logs that contains ‘File: YYYY-MM-DD.dat’. The YYYY-MM-DD is the $__to in YYYY-MM-DD format.

  • How are you trying to achieve it?
    The query is:
    {job=“some_job”, host=“$env”} |~ `File: ${__to:date:YYYY-MM-DD}.dat`

  • What happened?
    It returns nothing

  • What did you expect to happen?
    It should returns the logs that contains ‘File: 2024-02-26.dat’, if the time range is from 2024-02-21 to 2024-02-26

The query inspector shows the ${__to:date:YYYY-MM-DD} does not work as documented. Also tried on, the query inspector also shows the ${__to:date:YYYY-MM-DD} is not interpreted as documented, although ${__to} or ${__to:date} is.

If ‘to’ of time range is 2024-02-27 23:59:59
${__to} returns 1709078399000
${_to:date} returns 2024-02-27T23:59:59.000Z
${_to:date:YYYY-MM-DD} returns 1709078399000__F__date:YYYY-MM-DD__F

Please advise. Thanks in advance.