Postgresql 12 CAST now()到目前为止不起作用
我发现数据库为什么会有以下结果很奇怪:Postgresql 12 CAST now()到目前为止不起作用,postgresql,postgresql-12,Postgresql,Postgresql 12,我发现数据库为什么会有以下结果很奇怪: my1db=# select now()::date; now ---------------------------- 2020-10-08 19:57:24.483647 (1 row) 但以下是我的另一个数据库的结果: my2db=# SELECT now()::date; now ------------ 2020-10-08 (1 row)
my1db=# select now()::date;
now
----------------------------
2020-10-08 19:57:24.483647
(1 row)
但以下是我的另一个数据库的结果:
my2db=# SELECT now()::date;
now
------------
2020-10-08
(1 row)
我的第一个DB不是从我的第二个DB中显示的铸造
1STDB OS-RHEL 7 dbversion-PostgreSql 12.2
2NDDB OS-RHEL 7 dbversion-PostgreSql 12.1 我能知道我错过了什么吗? 这就是为什么我没有从我的申请中得到正确结果的原因 编辑(*删除的图像):
1STDB 2NDDB-cast的行为正常
为什么是演员?使用当前日期有什么问题?我有一个字段sendlog_dt|timestamp,没有时区,我想将它转换为日期,sendlog_dt::date。根据检查将其强制转换为::date两个服务器都会给出不同的结果,使用强制转换(sendlog_dt As date)的结果是相同的,那么您应该向我们展示一个不同的示例。我当前的sendlog_dt默认值为:timestamp without time zone |'now'::text::timestamp without time zone是否有人添加了自己的
now()
是否将函数添加到该数据库<代码>\df*。现在将是追踪这一点的开始。还是有人玩弄了演员?选择'10/08/20 7:15':时间戳::日期代码>返回`
template1=# \dC date
List of casts
Source type | Target type | Function | Implicit?
-----------------------------+-----------------------------+--------------+---------------
date | text | (with inout) | yes
date | timestamp without time zone | timestamp | yes
date | timestamp with time zone | timestamptz | yes
timestamp without time zone | date | date | in assignment
timestamp with time zone | date | date | in assignment
(5 rows)
template1=# select castfunc::regproc from pg_cast where casttarget = 'date'::regtype;
castfunc
------------------------
pg_catalog."timestamp"
pg_catalog."timestamp"
pg_catalog."timestamp"
(3 rows)
template1=# select castfunc::regproc, proname, proowner, prosrc, rolname from pg_cast, pg_proc, pg_authid where casttarget = 'date'::regtype and castfunc = pg_proc.oid and proowner = pg_authid.oid;
castfunc | proname | proowner | prosrc | rolname
------------------------+-----------+----------+-----------------------+---------
pg_catalog."timestamp" | timestamp | 10 | date_timestamp | pgadmin
pg_catalog."timestamp" | timestamp | 10 | timestamptz_timestamp | pgadmin
pg_catalog."timestamp" | timestamp | 10 | timestamp_scale | pgadmin
(3 rows)
psql (12.1)
Type "help" for help.
template1=# \dC date
List of casts
Source type | Target type | Function | Implicit?
-----------------------------+-----------------------------+-------------+---------------
date | timestamp without time zone | timestamp | yes
date | timestamp with time zone | timestamptz | yes
timestamp without time zone | date | date | in assignment
timestamp with time zone | date | date | in assignment
(4 rows)
template1=# select castfunc::regproc from pg_cast where casttarget = 'date'::regtype;
castfunc
-----------------
pg_catalog.date
pg_catalog.date
(2 rows)
template1=# select castfunc::regproc, proname, proowner, prosrc, rolname from pg_cast, pg_proc, pg_authid where casttarget = 'date'::regtype and castfunc = pg_proc.oid and proowner = pg_authid.oid;
castfunc | proname | proowner | prosrc | rolname
-----------------+---------+----------+------------------+----------
pg_catalog.date | date | 10 | timestamp_date | postgres
pg_catalog.date | date | 10 | timestamptz_date | postgres
(2 rows)