I am trying to convert a date from string to TDate by using the StrToDate method, however when I pass a date to it in the format yyyy/mm/dd it gives me this error: '''2013/11/12'' is not a valid date'. Any ideas what I'm doing wrong? Thanks
var
newDate: TDate;
begin
newDate := StrToDate(sDate);
end;
The overloaded version of
StrToDate()
that takes only astring
as input uses the user's default locale settings from the OS. The error means the string does not match the user's locale format for dates.Use the overloaded version of
StrToDate()
that accepts aTFormatSettings
as input so you can specify the desired format: