CDate 型キャスト
CDateは文字列を日付型に変換する関数です。
Delphiでは String型から日付型へ変換するには StrToDate を使用します。
TwoDigitYearCenturyWindow を使うと年を下二桁だけで表現した値をどう変換するかを指定できます。
| ■ StrToDateの例 |
procedure TForm1.Button1Click(Sender: TObject);
var
s : string;
dBirth : TDateTime;
begin
s := '01/12/28';
TwoDigitYearCenturyWindow := 0;
dBirth := StrToDate(s);
ShowMessage(FormatDateTime('yyyy/mm/dd',dBirth)); //結果は 1901/12/28
TwoDigitYearCenturyWindow := 50;
dBirth := StrToDate(s);
ShowMessage(FormatDateTime('yyyy/mm/dd',dBirth)); //結果は 2001/12/28
end;
|
関連項目
Date 日付
DateSerial 数値>日付
DayOfWeek 曜日
Format 書式
Now 日付/時刻
Weekday 曜日