I would like to display a date field as a label. The data is from a shapefile. The field in question is a date field.

When I use the date field for the label, it displays in the yyyy/mm/dd format. I would like to get it to the dd/mm/yyyy format.

Is this possible. I know in MapInfo I would use the FormatDate function, I wondered whether something similar existed in QGIS.

2 Answers 2


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:


Substring syntax is:


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

  • 1
    It is not a good idea to edit dbf outside of a GIS program because the ObjectID field will not carry over into excel. forums.esri.com/Thread.asp?c=93&f=987&t=302104
    – artwork21
    Aug 26, 2011 at 14:59
  • @artwork21 - Thanks, I will delete my answer shortly.
    – dassouki
    Aug 26, 2011 at 16:06
  • 3
    The thread referenced by @artwork21 documents a fundamental user error: when you sort the dbf, you destroy the connection between it and the features. (OID is a complete red herring; it's not used in the shapefile structure.) Provided you don't insert rows, delete rows, or reorder rows when editing the .dbf file, you'll be ok. Consider re-opening your reply in light of this.
    – whuber
    Aug 26, 2011 at 21:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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