I use QGIS 3.34 Prizren. I have an attribute field of
date type. Unfortunately, years are shown only with two digits:
23 instead of
2023. As a historian, this is really bad as it could be also 1923, 1823 etc. I know that internally, QGIS uses the correct, 4-digit year values. But for reading the attribute table, I want to see the full numbers.
How can I show the date in a format with years with actual, four-digit numbers?
What I tried
I tried to use
format_date ("date",'dd. MM. yyyy'), however, to no avail: in the preview, the desired format shows up, but when the field is created, all values are set to
NULL. This applied to temporary scratch layers as well as to Geopackage layers.
I also tried Menu Settings > Options > General. I can change the
Locale settings, but this does not affect the two-digit representation of the years.
Edit: The issue seems to be a newer one, as a year before (must have been QGIS 3.28), with the same settings, I had 4-digit numbers for the year (compare with 2nd screenshot below).
Setting the locals to
"French France" works (after restart of QGIS, thanks for the hint @user30184). However, I would like to get 4-digit years in my locale
"German Switzerland" as it was possible in older versions.
It is also strange that in my Windows 10 system Region settings, the year appears in 4 digits, even the "short version" (see screenshot, highlighted in red). It seems that in newer versions, QGIS does not respect system settings...
I could, of course, create a new field of type text/string and create a correctly looking date, but I try to avoid this as it is not very elegant and error prone.