Mega Code Archive

 
Categories / Delphi / Variables
 

Shortdateformat - compact version of the date to string format

var ShortDateFormat : string; Description The ShortDateFormat variable provides the short (compact) formatting used for default date to string conversion. It is used by the DateToStr, DateTimeToStr and DateTimeToString routines (the latter when the 'c' or 'ddddd' formatting is used). The following formatting character strings can be used in the ShortDateFormat string: y = Year last 2 digits yy = Year last 2 digits yyyy = Year as 4 digits m = Month number no-leading 0 mm = Month number as 2 digits mmm = Month using ShortDayNames (Jan) mmmm = Month using LongDayNames (January) d = 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_SSHORTDATE Related commands DateTimeToStr Converts TDateTime date and time values to a string DateTimeToString Rich formatting of a TDateTime variable into a string DateToStr Converts a TDateTime date value to a string FormatDateTime Rich formatting of a TDateTime variable into a string LongDateFormat Long version of the date to string format Example code : Illustrating customised ShortDateFormat setting var myDate : TDateTime; begin myDate := StrToDate('29/02/2000'); // Display using the default ShortDateFormat ShowMessage('29/02/2000 using default = '+DateToStr(myDate)); // Change the display formatting ShortDateFormat := 'dddd dd mmmm yyyy'; ShowMessage('29/02/2000 using dddd dd mmmm yyyy = '+DateToStr(myDate)); end; Show full unit code 29/02/2000 using default = 29/02/2000 29/02/2000 using dddd dd mmmm yyyy = Tuesday 29 February 2000