【发布时间】:2015-10-06 09:17:44
【问题描述】:
我的 PostgreSQL 数据库中有一个列,格式为 timestamp without time zone。我想使用以下代码保存当前日期:
MyStoredProc.ParamByName('date').Value := FormatDateTime('yyyy-mm-dd hh:nn:ss.zzz', Now);
我的存储过程中的date 值声明为DateTime,但将其设置为PgTimeStamp 也无济于事。第一列是在 PostgreSQL 中创建的,时间戳工作正常,但第二列,我试图从我的代码中保存数据,总是显示零。
我做错了什么?
【问题讨论】:
-
MyStoredProc.ParamByName('date').Value := 'now()::timestamp with time zone';(在 Delphi 环境中未经测试) -
我使用与您类似的代码在我的 PostgreSQL 数据库中保存
TDateTime。我的字符串格式是一样的。我的数据库字段是creationTime TIMESTAMP DEFAULT NOW() -
你为什么不使用
dd/mm/yy hh:mm:ss = 05/06/49 01:02:03delphi formats? -
@Dmitry 因为 postgresql 期望年-月-日时:分:秒.ms 格式
标签: postgresql delphi delphi-10-seattle