I have date values with the format d-m-yyyy in QGIS. They are in string field. I want to convert them into date values with the format yyyy-mm-dd. I want them in a date field.
Can this be done without doing something in Python?
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.
Sign up to join this communityI would recommend to use the Field calculator
.
Expression would be:
to_date(
concat(regexp_substr("old_date", '([^-]+$)'),
'-',
lpad(regexp_substr("old_date", '[-](\\d*)[-]'), 2, 0),
'-',
lpad(regexp_replace("old_date", '([-].*$)', ''), 2, 0)
)
)
Please replace "old_date"
by your actual string field.
1-2-2013
instead of01-02-2013
?