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?

  • Which software are you using or want to use?
    – pathmapper
    Jun 13, 2018 at 12:23
  • Sorry, QGIS 3.0
    – Rob
    Jun 13, 2018 at 12:39
  • Can you give examples on how your data looks if your format is d-m-yyyy please? Do you have dates like 1-2-2013 instead of 01-02-2013?
    – Joseph
    Jun 13, 2018 at 12:55
  • Yes, that's correct! The answer of @Kazuhito down here works perfect btw!
    – Rob
    Jun 13, 2018 at 13:15
  • @Rob - Great! Don't forget to accept his answer by clicking the green-faded tick on the left-hand side :)
    – Joseph
    Jun 13, 2018 at 13:22

1 Answer 1


I would recommend to use the Field calculator.

Expression would be:

  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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.