3

I have the date at which a pipe was laid. I want to create a field giving the age of the pipe in years. How do I do this in QGIS?

Vince
  • 20,017
  • 15
  • 45
  • 64
TraineeGIS
  • 31
  • 3

2 Answers2

5

Or use the age function

year(age(now() ,"yourdatefield"))
csk
  • 24,827
  • 3
  • 32
  • 70
  • Sometimes I get comfortable using some function and just forget that there might be another one that saves some time... :P – Gabriel Mar 29 '19 at 18:25
2

From the field calculator, this expression could do the trick:

year(now()) - year('the laying date')

Check if the date format will work, but aside from that, it should be pretty easy. The laying date can be replaced by a field value.

Gabriel
  • 3,136
  • 13
  • 33