3

My expression:

day(now()) || '/' || month(now()) || '/' || year(now())

returns current date as 15/4/2019, but I want to get the date in dd/mm/yyyy format i.e. 15/04/2019.

How can I get that using QGIS desktop version 2.18.12?

6

You need to use the format_date expression.

format_date(now(),'dd/MM/yyyy')

Please read the documentation of the format_date expression in QGIS Expression dialog to have all possibilities.

enter image description here

  • It returns date like 15/53/2019....which is impossible. – Keshav Sharma Apr 15 at 13:25
  • QGIS 2.18.12 is very old. The last of the 2.18 is 2.18.28 from January 2019. Maybe a bug has been fixed in the mean time? And QGIS 2.18 is not maintained anymore. Do you have the MM expression in your expression dialog documentation? – etrimaille Apr 15 at 13:28
  • Yeah, 'MM' seems to be working fine, I think 2.18 wrongly reads 'mm'. – Keshav Sharma Apr 15 at 13:33
  • Thankyou for your help. – Keshav Sharma Apr 15 at 13:34
  • MM is working fine for me on 2.18.28 – etrimaille Apr 15 at 13:34

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.