I have a shapefile with polygons. Each polygon contains a date (fully written in text, for example: '2 june 2018') in the attribute table. This field is format 'text'. Now, I would like to convert these fields / this column to a new column with the dates written in numbers (for example '02/06/2018'). The new fields have to be formatted as 'date'.
Does anybody know how to do this quickly in the field calculator using a formula?
-
docs.qgis.org/3.28/en/docs/user_manual/expressions/…Erik– Erik2023年09月05日 08:17:29 +00:00Commented Sep 5, 2023 at 8:17
1 Answer 1
First I'd like to note that only the international date format is of type "date"
: yyyy-mm-dd
. All other types are just representations of this date and depend e.g. on your settings about locales in QGIS. You can change these in Settings --> Options --> General. That being said, you can use this expression:
to_date('2 june 2018', 'd MMMM yyyy', 'en')
respectively replace the date with your field.
-
Hi MrXsquared, works perfectly! Although I changed the 'en' to 'nl', because the names of the months are written in Dutch. Works! Thanks!!BramV– BramV2023年09月05日 11:44:49 +00:00Commented Sep 5, 2023 at 11:44
Explore related questions
See similar questions with these tags.