I have a SQL date field that’s in a variant and when I do VarToStr on my PC I get dd/mm/yyyy but on a customers PC (Both of us have the exact same Windows short and long date formats) it’s converted to dd-mm-yyyy.
Is there something else on a PC that controls date formats?
You could assign the var to a TDateTime var and then use the FormatDateTime to have it appear in any way that you want it to, independent of windows settings.
I over simplified what I assumed was the issue that’s now been fixed.
Code was
case fColDataType of
sdtDATE: begin
Result := QuotedStr(FormatDateTime(‘yyyymmdd’, fColValue));
end;
Fixed code is:
case fColDataType of
sdtDATE: begin
Result := QuotedStr(FormatDateTime(‘yyyymmdd’,
VarToDateTime(fColValue)));
end;
I fixed it by doing VarToDateTime(fColValue)
Error message that was being captured was “Could not convert variant of type
(UnicodeString) into type (Double)”.
I was wondering if differing version of the dll’s associated with getting
the data from a MS SQL server would have any bearing on it?
Just weird that even when we had the same Windows date formats that and I
was using VarToStr in debug logs that I was getting dd/mm/yyyy vs client
getting dd-mm-yyyy when processing the exact same data record.