How to check if a date exists (Views: 27)
Problem/Question/Abstract: Is there a possibility to check if a date exists (e.g. 35.3.2001)? Answer: function DateExists(Date: string; Separator: char): Boolean; var OldDateSeparator: Char; begin Result := True; OldDateSeparator := DateSeparator; DateSeparator := Separator; try try StrToDate(Date); except Result := False; end; finally DateSeparator := OldDateSeparator; end; end; procedure TForm1.FormCreate(Sender: TObject); begin if DateExists('35.3.2001', '.') then begin {your code} end; end; |