From a2018b421f3e9b288f216d1af14e697f3a8cc817 Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Sat, 30 May 2015 14:11:22 +0000 Subject: [PATCH] MSSQL: Again, try to use some universal date/time format, by injecting a "T" between the date and the time portion. This time with a TRegExpr instead of a TDateTime object. See http://www.heidisql.com/forum.php?t=18441 --- source/dbconnection.pas | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/source/dbconnection.pas b/source/dbconnection.pas index 68472e01..be117ee1 100644 --- a/source/dbconnection.pas +++ b/source/dbconnection.pas @@ -3944,10 +3944,24 @@ end; function TDBConnection.GetDateTimeValue(Input: String; Datatype: TDBDatatypeIndex): String; +var + rx: TRegExpr; begin // Return date/time string value as expected by server - // Not sure why there was a conversion required in earlier versions. - Result := Input; + case Parameters.NetTypeGroup of + ngMSSQL: begin + rx := TRegExpr.Create; + rx.Expression := '^(\d+\-\d+\-\d+)\s(\d+\:.+)$'; + Result := Input; + if rx.Exec(Input) then begin + // Inject "T" between date and time, for MSSQL. See http://www.heidisql.com/forum.php?t=18441 + Result := rx.Match[1] + 'T' + rx.Match[2]; + end; + rx.Free; + end; + else + Result := Input; + end; end;