I have a shapefile with a timestamp (string type) and id field (string type):
timestamp tag id
2017-11-14 09:03:00 1 0
2017-11-14 13:03:00 1 1
2017-11-14 20:03:00 1 2
2017-11-14 09:03:00 2 3
2017-11-14 13:03:00 2 4
I'm trying to find the time difference in hours between consecutive points by id using the Field Calculator tool in QGIS.
I tried the following expression but the results returned NULL
. When I try to convert the timestamp field to DateTime using to_datetime function I get an error that it can not convert to DateTime. Any other suggestions on calculating the time difference with the Field Calculator in QGIS?
second(age(attribute($currentfeature, to_datetime(timestamp)),
attribute(get_feature_by_id('points',$id-1), to_datetime(timestamp))))