I have a dataset in QGIS that I originally created in ArcMap. It has two fields for dates, let's call them 'date_from' and 'date_to'. Both of these fields contain only a year i.e. '2012' and nothing else, this was originally sufficient for my needs. They are of the double type.

Upon moving over to QGIS I see that dates need to be in the format 'yyyy-mm-dd'. How would I best go about creating new fields to add the full dates using what I already have? Note that the first of Jan and last of Dec would be sufficient for the new 'from' and 'to' fields.

1 Answer 1


You can build the full date

to_date( year_from || '-01-01')

to_date( year_to || '-12-31')

enter image description here

enter image description here

  • Brilliant, that did it thank you! Sep 15, 2020 at 12:30

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.