At 3.28.6, I have a GeoPackage table with a date field which always displays in the attribute table window as M/d/yyyy. I would like it to display as the ISO 8601 standard yyyy-MM-dd.

Using the Field Calculator I try format_date("date_field", 'yyyy-MM-dd'). No error occurs, but the result still displays M/d/yyyy.

How do I display a date field in the attribute table window as yyyy-MM-dd?

  • There may be a difference between 'yyyy' and 'YYYY' in formatting. There's certainly a differences between '%y' and '%Y' and '%m' and '%M' in strftime. Have you tried using 'YYYY-MM-DD'?
    – Vince
    May 3 at 22:57
  • Alas, neither YYYY or DD are recognized by the Field Calculator.
    – Stu Smith
    May 4 at 2:58

1 Answer 1


You shouldn't need to use the Field Calculator. If you go to Layer Properties -> Attributes Form, you can set the Widget Type to Date/Time and the Field Format to yyyy-MM-dd. See screenshot:

enter image description here

Attribute table below:

enter image description here

  • This is a great answer! But it requires modifying each and every qgz file, which got me rethinking my OP... in retrospect I was thinking along the lines of being able to customize a program-level QGIS setting, so that date or datetime fields always displayed in the desired format, without having to modify every project. It also seems odd that the default QGIS date format is M/d/yyyy rather than the ISO 8601 standard of yyyy-MM-dd. I may post a new question along these lines if nothing appears here in the next few days.
    – Stu Smith
    May 5 at 3:10
  • 1
    Pretty sure QGIS default date format is taken from the System. For example, mine is d/MM/yyyy rather than M/d/yyyy (eg 31/12/2022). But if you want to ask your followup, ask it as a new question - the comments are just for clarifications (and it will help other people who might have the same question!). May 5 at 4:12

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.