Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 错误:列";事件“开始”;为不带时区的timestamp类型,但表达式为interval类型_Sql_Postgresql - Fatal编程技术网

Sql 错误:列";事件“开始”;为不带时区的timestamp类型,但表达式为interval类型

Sql 错误:列";事件“开始”;为不带时区的timestamp类型,但表达式为interval类型,sql,postgresql,Sql,Postgresql,我目前正在插入/更新列上没有时区数据的随机时间戳,但PostgreSQL不断给我错误错误:列“event\u start\u adj”的类型为timestamp,没有时区,但表达式的类型为interval,提示说:提示:您需要重写或强制转换表达式。 我的问题是: UPDATE dashboard.event SET event_start_adj = (random() * ('2020-01-01 00:00:00'::timestamp without time zone - '2020-0

我目前正在插入/更新列上没有时区数据的随机时间戳,但PostgreSQL不断给我错误
错误:列“event\u start\u adj”的类型为timestamp,没有时区,但表达式的类型为interval
,提示说:
提示:您需要重写或强制转换表达式。

我的问题是:

UPDATE dashboard.event SET event_start_adj = (random() * ('2020-01-01 00:00:00'::timestamp without time zone - '2020-04-16 23:59:59'::timestamp without time zone )) WHERE event_id = 2286 

如果您有任何帮助,我们将不胜感激。

您会收到此错误,因为您的查询结果是一个时间间隔,而不是一个时间戳。您需要在时间间隔中添加第一个日期以获得时间戳

UPDATE dashboard.event SET event_start_adj = '2020-01-01 00:00:00'::timestamp + (random() * ('2020-01-01 00:00:00'::timestamp without time zone - '2020-04-16 23:59:59'::timestamp without time zone )) WHERE event_id = 2286

检查这里:这是我试图使用的一个,正如我的代码中看到的,但它不会工作