Select data from last month


I want to select all data from last month depends on actually date.

Example: today 2018-06-21 -> I need all datas from 2018-05-01 - 2018-05-31

SELECT * FROM “” WHERE time >= 1525125600000000000 and time <= 1527803999000000000
I will get it. But the Timerange should variable (depends on “today”)

somthing like this:

SELECT * FROM “” WHERE time = month(today)-1

the last 30 days I will get with time < now() - 30d

Is this possible?


I think you should be able to run a query like this:

select * from “” where time <= now() and time >= now() - 30d

Thank you for replay.
But I need the data from previous month fot for last 30 days().

Like SELECT * FROM “” WHERE time =lastmonth()


This is a popular feature request that’s on our radar, and will be supported in our new query engine, Flux.

Thank you for Information


1 Like

How is this accomplished using Flux? The closest I could get is using this, but that still does the last 30 days, not the current month.
|> range(start:-30d, stop:now())
Thanks for your help!

Hi @jordanwade33 , welcome to the community ,

It is not easy to implement ,but as a workaround you can use
An Absolute time range in that link you can see following example …

  |> range(start: 2018-11-05T23:30:00Z,      stop: 2018-11-06T00:00:00Z)

Ps : You can see the status of the implementation if you follow the link @katy has posted,

Hope this helps … best regards,

Hi Marc, Thanks for the quick reply. I’m new to InfluxDB but I’m loving all the things I’m finding it capable of doing.

After your reply, I read through the entire link that you mentioned and there was a lot of good things there. My goal is to have dynamically updated ranges, so I’ve decided to not go with absolute time ranges like you recommended. I did come across some people using window() to get what I’m looking for.

|> window(every: 1mo, period: 1mo)

I don’t quite have enough data yet to tell if it’s working, but I’ll keep an eye on it and continue to play with it. Thanks again!