[Qgis-developer] datetime difference between 2 datetimes in Field Calculator

Nyall Dawson nyall.dawson at gmail.com
Mon May 23 02:41:11 PDT 2016


On 23 May 2016 at 19:12, Richard Duivenvoorde <rdmailings at duif.net> wrote:
> I have a start-datetime (string) and a an end-datetime (string) in the
> attributes of my vector data.
>
> I can use the  to_datetime(str) function in the Field Calculator to create
> DateTime objects from these.
>
> But now it would be cool to check the time-difference between those two
> (called timespan?).
> I did not find a function for those...

Use the age() function. That takes two datetimes and returns an
interval length between them. You can extract the
seconds/minutes/hours/etc from an interval type using the seconds(),
minutes(), ... etc functions.

Hope that helps!
Nyall



>
> Any hints?
>
> If I did not miss something, I think there is not even a Qt function for
> this...
>
> A function to add could be: 'to_timemillies', then the user could create
> timemillies from the DateTime-objects, and do some calculation on those
> him/herself...
>
> Would that be usefull?
>
> Regards,
>
> Richard Duivenvoorde
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer


More information about the Qgis-developer mailing list