Ask Your Question
3

How can I convert the dates in string format from my InfluxDB query to ascending order?

asked 2023-01-02 11:00:00 +0000

pufferfish gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2022-05-20 01:00:00 +0000

bukephalos gravatar image

Assuming the dates in string format are in ISO8601 format, you can use the "ORDER BY" clause in your InfluxDB query to sort the results in ascending order based on the dates.

The basic syntax for sorting the results in ascending order using "ORDER BY" is as follows:

SELECT <fields> FROM <measurement> WHERE <conditions> ORDER BY time ASC

Here, "time" is the default time field in InfluxDB, and "ASC" is used to indicate ascending order. You can modify this query to suit your specific requirements.

For example, if your query is:

SELECT temperature FROM sensors WHERE location='kitchen'

You can modify it to sort the results in ascending order based on time, as follows:

SELECT temperature FROM sensors WHERE location='kitchen' ORDER BY time ASC

This will return the results sorted in ascending order based on the time field (assuming it is in ISO8601 format).

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-01-02 11:00:00 +0000

Seen: 8 times

Last updated: May 20 '22