I want to calculate the points of two different data in time

Hi, I’m using Grafana with InfluxDB SQL as the data source, and I’m outputting data values by specifying codes in the select field. I’m using two codes in the select function to output data, where the x-axis represents time and the y-axis represents the values corresponding to the codes.

grafana data screen

I want to calculate [(end time of the first data)-(start time of the second data)] (Red Points data - Blue Points data) based on the data points. Is there a way to convert data points to time values and output only the time values?
Any help would be greatly appreciated!

And Thank you for reading this and I hope you have a great day!

Hi @acciotome

I think you might need to use a function like

EXTRACT(HOUR FROM "time") AS hour

See this example which uses this function. Also, the people on the InfluxDB forum might also be able to help.