I would like to calculate the number of days between two dates. The first date is written in attribute table [YYYY-MM-DD] (creation date) and the second is today [now()]. The goal is, to get the age of every feature. I need it as QGIS expression to create a virtual field.

date1 (attribute in table) - now() = age (as virt. field)

1 Answer 1


You can compute the duration between the two dates using the age function. Since it returns a timespan, you can then extract the number of days from it.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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