0

I'm coming from Delphi 2007 to Delphi 10.3.3 .

In D2007 i used the commands below to make sure the date would be handled by the app with the desired format :

shortdateformat := 'dd/mm/yyyy';
dateseparator := '/';

Now the same commands would fail on D10.3.3 with the error below :

[dcc32 Error] : E2003 Undeclared identifier: 'shortdateformat'

How to do the same thing on the new Delphi ?

Thanks

delphirules
  • 6,443
  • 17
  • 59
  • 108

1 Answers1

3

I just learned that i need to use these commands instead :

FormatSettings.shortdateformat := 'dd/mm/yyyy';
FormatSettings.dateseparator := '/'; 
delphirules
  • 6,443
  • 17
  • 59
  • 108
  • 9
    Rather than using the global `FormatSettings` variable, it is usually preferable to instead pass a local `TFormatSettings` variable to whatever formatting function you are using, eg: `var fmt: TFormatSettings; fmt := TFormatSettings.Create; fmt.ShortDateFormat := 'dd/mm/yyyy'; fmt.DateSeparator := '/'; (..., fmt);` The global variables are not thread-safe, which is why `TFormatSettings` was even introduced in the first place. – Remy Lebeau Feb 12 '20 at 00:44