Date manupilations

Dear Sir/Madam,

My date time format is as following:

Apr 28 09:27:01

How do I do the math please? For example, I wanna find out date time 5 minutes before the above date. In MySQL datetime format is 2018-04-28 09:27:01 and the math function to get 5 minutes earlier is:

DATE_SUB(‘2018-04-28 09:27:01’, INTERVAL 5 MINUTE)

Do you have similar function I can use please?
Sorry if my question is too newbie.

Please help.

I think the Data Exploration>Time Syntax section of the InfluxDB documentation, and the example below in particular, might answer your question.

Example 5: Perform basic arithmetic on an RFC3339-like date-time string:

> SELECT "water_level" FROM "h2o_feet" WHERE time > '2015-09-18T21:24:00Z' + 6m

name: h2o_feet
time                   water_level
----                   -----------
2015-09-18T21:36:00Z   5.066
2015-09-18T21:42:00Z   4.938

Thanks a lot for that.

I knew how to that use influxdb’s time column and was just wonder if I can do the same for my own datetime column with format, e.g., “May 1 03:48:01” - looks likely this is not possible.


When you say your own datetime column, do you mean that you’re storing a date and time as a string in a field of an InfluxDB measurement?

That would be an unusual use case for a time-series, I’d be curious to hear more about what you’re working on. I’m having trouble coming up with a scenario where I’d need to store a timestamped timestamp.

HAProxy log has own date time field and it is input to influxdb.

Is it possible to do manipulation the same way as the influxdb added time column please?


If you are storing the time column from your HAProxy logs in a string in InfluxDB, then no, it is not possible to perform time operations on that data.

However, it doesn’t sound like you need two timestamps. Instead of having the database create a timestamp when it receives a point, you can pass it a time for each point that you send—in this case, you would parse the time from the HAProxy log entry and use that as the timestamp for the point.