I have a shapefile with all the buildings of the region. In the attribute table I have a field containing the date that the individual buildings have been built. I need to count how many buildings have been built in the region in certain years.

How can I change the specific dates (e.g. 15.2.2008) (the field is text form, not numeric) into year (2008)?

I use both QGIS and ArcGIS (ArcInfo), so any tips for either programme would be great.

  • 1
    What software are you using for this? Jun 16, 2016 at 13:33

2 Answers 2


One way is to create a new field containing your year, so you can count on it, and keep the full date for a later use. Use the function 'right' to fill your new field with the last four characters of your date field (only the year) :

right(  "dateField" , 4 )

This works with QGIS, but equivalent functions exists in other softwares.


Assuming you are using QGIS because you mention "attribute table", as Pierre states , you can add a new field and populate it with the year. Another function that is available is YEAR(date):

From the expression dialog:

function year

Extract the year part from a date, or the number of years from an interval.

Date variant

Extract the year part from a date or datetime.




date a date or datetime value


  • year('2012-05-12') → 2012

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.