Re: [Qgis-developer] datetime difference between 2 datetimes in Field Calculator
Nyall Dawson schreef op 2016-05-24 09:21: FYI - as of https://github.com/qgis/QGIS/commit/8ddcf76 you can now just directly calculate date/time/datetime differences using "-", eg to_date('2016-03-04')-to_date('2016-03-01') This will return an interval object which you can then use seconds(), minute(), etc on. kewl! Thanks again :-) ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer
Re: [Qgis-developer] datetime difference between 2 datetimes in Field Calculator
Win! On Tue, 24 May 2016 5:21 pm Nyall Dawson wrote: > On 23 May 2016 at 21:21, Richard Duivenvoorde wrote: > > Nyall Dawson schreef op 2016-05-23 11:41: > >>> > >>> 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! > > > > > > Ah :-) definitely... Did find see that one... > > FYI - as of https://github.com/qgis/QGIS/commit/8ddcf76 you can now > just directly calculate date/time/datetime differences using "-", eg > > to_date('2016-03-04')-to_date('2016-03-01') > > This will return an interval object which you can then use seconds(), > minute(), etc on. > > Nyall > > > > > > Thanks! > > > > Richard > ___ > Qgis-developer mailing list > Qgis-developer@lists.osgeo.org > List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer > Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer
Re: [Qgis-developer] datetime difference between 2 datetimes in Field Calculator
On 23 May 2016 at 21:21, Richard Duivenvoorde wrote: > Nyall Dawson schreef op 2016-05-23 11:41: >>> >>> 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! > > > Ah :-) definitely... Did find see that one... FYI - as of https://github.com/qgis/QGIS/commit/8ddcf76 you can now just directly calculate date/time/datetime differences using "-", eg to_date('2016-03-04')-to_date('2016-03-01') This will return an interval object which you can then use seconds(), minute(), etc on. Nyall > > Thanks! > > Richard ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer
Re: [Qgis-developer] datetime difference between 2 datetimes in Field Calculator
On 23 May 2016 at 19:12, Richard Duivenvoorde 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@lists.osgeo.org > List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer > Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer
[Qgis-developer] datetime difference between 2 datetimes in Field Calculator
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... 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@lists.osgeo.org List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer