Skip to content

SQL docs are missing examples of filtering by dynamic date ranges #4852

@8none1

Description

@8none1

I've been trying to work out how to filter my results to those which have a timestamp of all of yesterday.

The docs talk about now() as a way to find today's date, but after that all the examples which SELECT a date range all use static timestamps. It is possible to write a query that will always return the results from all of yesterday without specifying the timestamps in the WHERE clause.

For example; this will filter to times that are in the range of all of yesterday (NB: I don't know if this is the correct way to do it, but it works for me, I think):

WHERE time > DATE_TRUNC('day', now()-interval '1 day') AND time <  DATE_TRUNC('day', now())

I think this is a valuable example and users would benefit from an example of how to do it.

Relevant URLs

Metadata

Metadata

Assignees

No one assigned

    Labels

    InfluxDB v3InfluxDB v3.0 (platforms using IOx)SQLgood-first-issueEasy update. Good for first timers!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions