INSERT into Group (Name,CreatedDate) VALUES ('Test',UTC_TIMESTAMP(), 1);
这是我用于在MySQL中插入当前日期时间的查询。 当我在PostgreSQL中使用它时,会出现以下错误。
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
********** Error **********
ERROR: function utc_timestamp() does not exist
SQL state: 42883
我已经尝试使用now()
,但它插入的格式是"2016-07-07 17:01:18.410677"
。 我需要以'yyyymmdd hh:mi:ss tt'
格式插入。
INSERT into Group (Name,CreatedDate) VALUES ('Test',UTC_TIMESTAMP(), 1);
如何在PostgreSQL的插入查询中插入当前日期时间,使用上述格式?
CURRENT_TIMESTAMP
甚至NOW()
。前者至少有精度参数。因此,CURRENT_TIMESTAMP(3)
将产生3个子秒数字(毫秒分辨率)。 - Dilettant