In my code I am facing a problem. Example code:
var
d1: tdatetime
begin
d1 := strtodatetime('23/02/2011 12:34:56');
end;
but it’s giving the error:
’23/02/2011 12:34:56′ is not valid
date and time
What’s wrong with what I am doing?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
the StrToDateTime function uses the
ShortDateFormatandDateSeparatorto convert the date part and theLongTimeFormatandTimeSeparatorto the time part. so you string must match with theses variables to convert the string to TDateTime. instead you can use the StrToDateTime with theTFormatSettingsparameter, to parse you string.check this sample