RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
SysUtils.DateSeparator Variable

DateSeparator is the character used to separate the year, month, and day parts of a date value.

Pascal
DateSeparator: Char;
C++
Char DateSeparator;

On Windows, the initial value is fetched from LOCALE_SDATE.  

C++ Examples: 

 

/*
This example uses a label and a button on a form. When the
user clicks the button, the current date displays in the
caption of the label. Because some of the date variables are
assigned new values, the format of the date in the label
changes. For example, if the date is 9/15/94, the date
displays as 9-15-1994.
*/
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  DateSeparator = '-';
  ShortDateFormat = "m/d/yyyy";
  Label1->Caption = DateToStr(Date());
}

 

Delphi Examples: 

{
This example uses a label and a button on a form. When the 
user clicks the button, the current date displays in the 
caption of the label. Because some of the date variables are 
assigned new values, the format of the date in the label 
changes. For example, if the date is 9/15/94, the date 
displays as 9-15-1994.
} 
procedure TForm1.Button1Click(Sender: TObject);
begin
  DateSeparator := '-';
  ShortDateFormat := 'm/d/yyyy';
  Label1.Caption := DateToStr(Date);
end;

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!