Browse Source

* Mantis #19567: PostgreSQL TIME datatype fix by Lacak2. milliseconds and not correcting fttime fields with epoch.

git-svn-id: trunk@18108 -
marco 14 years ago
parent
commit
a09a7f1b2e
1 changed files with 6 additions and 4 deletions
  1. 6 4
      packages/fcl-db/src/sqldb/postgres/pqconnection.pp

+ 6 - 4
packages/fcl-db/src/sqldb/postgres/pqconnection.pp

@@ -601,11 +601,11 @@ begin
           begin
           case AParams[i].DataType of
             ftDateTime:
-              s := FormatDateTime('yyyy-mm-dd hh:nn:ss', AParams[i].AsDateTime);
+              s := FormatDateTime('yyyy-mm-dd hh:nn:ss.zzz', AParams[i].AsDateTime);
             ftDate:
               s := FormatDateTime('yyyy-mm-dd', AParams[i].AsDateTime);
             ftTime:
-              s := FormatDateTime('hh:nn:ss', AParams[i].AsDateTime);
+              s := FormatDateTime('hh:nn:ss.zzz', AParams[i].AsDateTime);
             ftFloat, ftBCD:
               Str(AParams[i].AsFloat, s);
             ftCurrency:
@@ -778,12 +778,14 @@ begin
           dbl := pointer(buffer);
           dbl^ := BEtoN(plongint(CurrBuff)^) + 36526;
           end;
-        ftDateTime, fttime :
+        ftDateTime, ftTime :
           begin
           pint64(buffer)^ := BEtoN(pint64(CurrBuff)^);
           dbl := pointer(buffer);
           if FIntegerDatetimes then dbl^ := pint64(buffer)^/1000000;
-          dbl^ := (dbl^+3.1558464E+009)/86400;  // postgres counts seconds elapsed since 1-1-2000
+          if FieldDef.DataType = ftDateTime then
+            dbl^ := dbl^ + 3.1558464E+009; // postgres counts seconds elapsed since 1-1-2000
+          dbl^ := dbl^ / 86400;
           // Now convert the mathematically-correct datetime to the
           // illogical windows/delphi/fpc TDateTime:
           if (dbl^ <= 0) and (frac(dbl^)<0) then