1
var MyDate:TDate; 
   MyDate:=Date;

How can I convert local myDate to my format: 31/12/2011?

RecodeDate?

Thanks!!!

maxfax
  • 4,281
  • 12
  • 74
  • 120

1 Answers1

5

Check the FormatDateTime function in your case you try this

FormatDateTime('dd/mm/yyyy',MyDate);
RRUZ
  • 134,889
  • 20
  • 356
  • 483
  • 1
    :) Thanks, why nothing was said about that function here: http://docwiki.embarcadero.com/RADStudio/en/Date_and_Time_Support ? – maxfax Aug 01 '11 at 03:15
  • @Maxfax - good question. It is in [Type conversion routines](http://docwiki.embarcadero.com/RADStudio/en/Type_conversion_routines), but a second reference would be good – Gerry Coll Aug 01 '11 at 04:36
  • 4
    Depending on your (and your clients) requirements, it may be better to use DateToStr(MyDate), as this will follow the current users locale settings, e.g. mm/dd/yyyy for US users, dd/mm/yyyy for UK etc. American software that always uses mm/dd/yy annoys (and confuses) me, so I try to extend the same courtesy that I would like. – Gerry Coll Aug 01 '11 at 04:40
  • there are some variables which contain the current date locales. see http://docwiki.embarcadero.com/VCL/en/SysUtils.ShortDateFormat – coding Bott Aug 01 '11 at 08:21