DayOfWeek (C++)
Description
This example uses an edit box and a button on a form. When you enter a date in the edit box in the format associated with the current locale (for example, the MM/DD/YY format in the US), the string entered is converted to a TDateTime value. This value is used to indicate the day of the week the date represents.
Code
void __fastcall TForm1::Button1Click(TObject *Sender)
{
char days[7][10] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };
TDateTime dtDate = StrToDate(Edit1->Text);
ShowMessage(Edit1->Text + String(" is a ") + days[dtDate.DayOfWeek() - 1]);
}
Uses
- System.SysUtils.DayOfWeek ( fr | de | ja )
- System.SysUtils.StrToDate ( fr | de | ja )