Formatting Dates in QGIS labels
Update: Expressions now support date formatting, for example
format_date('2012-05-15','dd.MM.yyyy') → '15.05.2012'
Currently, there is work going on related to "expression based labeling": http://hub.qgis.org/issues/3488.
For now, you can use Field Calculator to convert your datetime string to a different format, e.g. YYYY/MM/DD to DD.MM.YYYY like this:
substr(date,8,2)||'.'||substr(date,5,2)||'.'||substr(date,0,4)
Substring syntax is:
substr(string,startpos,length)
If you can open the shape.dbf file in your favorite spreadsheet editor:
- Create a new column, call it
temp_date
. - Copy and pate the old date data to temp_date
- Split that column using
text to data
feature by character\
or whichever happens to be your date splitter - Reorganize the columns in the order you want
- Create a new column
new_date
- In new_date use the following formula
=A1 & "/" & B1 & "/" & C1
. Of course you need to use the proper fields and not the ones I mentioned.
Of course there could be a default way for QGis to handle date formats, but I haven't seen it. Perhaps, play around wit the field calculator if that helps at all
I'm sure there is an option to do it using the qgis python console, I don't suspect this will be a big deal either using the time /time date modules or just a generic str.replace or reg expression. I'm not verse with the api so I can't help there