none
Date Conversion Error

    Question

  • I am running the same Delphi 2007 code on two Windows 7 machines using an SQL server database on a remote server. When I run the code one one machine it crashes on the following line: aQuery.FieldByName('curr_date').asDateTime with exception 'EConvert Error: 2013-1-25 00:00:00.000 is not a valid date and time' but on the other machine the code runs without any issues. The 'curr_date' field is a Datetime2 datatype. I found that if I check the value of the 'curr_date' as a string (i.e. aQuery.FieldByName('curr_date').asString), on one machine the date is formatted as '1/25/2013' and on the other machine the date is formatted as '2013-1-25 00:00:00.000'. The machine on which the date is formatted as '2013-1-25 00:00:00.000' is the machine on which the code crashes. The regional settings in Control Panel are identical on both machines. Anyone know what the problem is?

    • Edited by OneCat Friday, October 18, 2013 2:42 PM
    • Changed type OneCat Friday, October 18, 2013 5:13 PM
    • Changed type Kalman TothModerator Friday, October 18, 2013 6:58 PM
    Friday, October 18, 2013 2:24 PM

Answers

All replies