[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?
l3m0nAsked:
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

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

  Days :=  Date1-StrToDate(DateFromSql, F);
 
0
 
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
uses
  DateUtils;

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

   Days := DaysBetween(Date1, DateFromSql);

  .....
0
 
l3m0nAuthor Commented:
I get it from mysql parser table not from data set:
Date:=StrToDate(UnicodeString(MYSQL_ROW^[4]));

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.
0
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.