DelphiBasics
LongDateFormat
Variable
Long version of the date to string format SysUtils unit
var LongDateFormat : string;
Description
The LongDateFormat variable provides the long (extended) formatting used for certain date to string conversions.
 
It is used by the DateTimeToString routine when the 'dddddd' formatting is used. The following formatting character strings can be used in the LongDateFormat string:
 
= Year last 2 digits
yy  = Year last 2 digits
yyyy  = Year as 4 digits
= Month number no-leading 0
mm  = Month number as 2 digits
mmm  = Month using ShortDayNames (Jan)
mmmm  = Month using LongDayNames (January)
= Day number no-leading 0
dd  = Day number as 2 digits
ddd  = Day using ShortDayNames (Sun)
dddd  = Day using LongDayNames  (Sunday)
Notes
The default value is set from LOCALE_SLONGDATE
Related commands
DateTimeToStrConverts TDateTime date and time values to a string
DateTimeToStringRich formatting of a TDateTime variable into a string
DateToStrConverts a TDateTime date value to a string
FormatDateTimeRich formatting of a TDateTime variable into a string
ShortDateFormatCompact version of the date to string format
 Download this web site as a Windows program.




 
Example code : Illustrating customised LongDateFormat setting
var
  myDate : TDateTime;
  formattedDate : string;

begin
  myDate := StrToDate('29/02/2000');

  // Display using the default LongDateFormat
  DateTimeToString(formattedDate, 'dddddd', myDate);
  ShowMessage('29/02/2000 using  default = '+formattedDate);

  // Change the display formatting
  LongDateFormat := 'dddd dd of mmmm yyyy';
  DateTimeToString(formattedDate, 'dddddd', myDate);
  ShowMessage('29/02/2000 using override = '+formattedDate);
end;
Show full unit code
  29/02/2000 using default = 29 February 2000
  29/02/2000 using override = Tuesday 29 of February 2000
 
Delphi Programming © Neil Moffatt . All rights reserved.  |  Home Page