I am preparing a field worker / QField project an would like to visualize green spaces based on the days that have elapsed since the last field worker has visited that site.

I am testing with a very basic data set with a field beeing automatically updated with the current date by now() on insert and update. The elapsed days since the last visit are beeing calculated via

day(age(now(), "Date"))

Now I would like to update the days elapsed since the last visit on a daily basis or on every QGIS/QField startup. Do you have any idea, how to trigger the above calculation automatically when starting the QGIS project?

visualization based on date

  • 1
    You may run the classification based on the expression you use to create the field - so no need to recalculate. Though I do not know, how this can be transported to QField. Otherwise, have a look at virtual layers.
    – Erik
    Jun 15, 2021 at 7:17

2 Answers 2


I think what you are looking for is a virtual field. It is a field based on an expression that is always evaluated and not stored in memory.

To do it you have to open the field calculator check the box Create a virtual field and then add your expression. day(age(now(), "Date")). This field will always be calculated when you see it.

Your date must be in appropriate format (your date stored are may be just a date format you use). Even if you store your date in a non-standard date format you can to transform it to be understand by QGIS. For your example the transformation should be make_date( right ("Date",4), left(right ("Date",7),2),left ("Date",2)).

I think it should work in Qfield, but I have never tried.

  • 1
    Thank you - gonna check this out and give report.
    – JackColt
    Jun 15, 2021 at 10:59

Yes I can confirm this is both working in QGIS and QField. Somehow on your mobile device you must restart the project from local file/folder not from the list of previously opened projects to see the updated calcultaion.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.