Calculate elapsed time between start & end of measurement etc

I’d like to calculate values like these from my InfluxDB measurements and display them in Grafana:

  • Time elapsed since the most recent value in the measurement (ie now() - last(time) if that were possible)
  • Time elapsed between the latest value in the measurement and the first (similarly last(time) - first(time) )

I understand from other posts that the time data isn’t something that can be accessed in ways like first(time).

However, is there any other way to perform calculations such as these please? Thank you.