[Delphi] StrToDate in 64bit system

Hello my application gets data from mysql database in format: 2022-12-12
It works in all windows but only in 32 bit system. When i try to use it in 64bit windows 7 i get error:
2022-12-12 is not a valid date. My code:
Days:= Date1-StrToDate(DateFromSql);

Open in new window

What is wrong in 64 bit system?
Who is Participating?
Ephraim WangoyaConnect With a Mentor Commented:

Since you get it as string and its yyyy/mm/dd, delphi is not expecting that format when performing StrToDate

You will have to specify the format yourself

   F: TFormatSettings;
  F.DateSeparator := '-';
  F.ShortDateFormat := 'YYYY-MM-DD';

  Days :=  Date1-StrToDate(DateFromSql, F);
Ephraim WangoyaCommented:

How do you get the value in the variable DateFromSql?

Instead of using a string to store the date, just store it in a real datetime variable

    DateFromSql: TDateTime;
   DateFromSql := Dataset.FieldByName('DateField').AsDateTime;

   Days := DaysBetween(Date1, DateFromSql);

l3m0nAuthor Commented:
I get it from mysql parser table not from data set:

Open in new window

i get other date too from server:
Date1 := GetURLAsString('http://www.flyffbot.pl/data.php');

Open in new window

I dont know why it works on x86 but on x64 didnt.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.