Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/9.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
在Presto或Postgres中,mysql date_format()等效于什么?_Mysql_Postgresql - Fatal编程技术网

在Presto或Postgres中,mysql date_format()等效于什么?

在Presto或Postgres中,mysql date_format()等效于什么?,mysql,postgresql,Mysql,Postgresql,从datetime2018-12-12 10:10:10到仅获取年-月,我通常在MySQL8.0中这样做 date\u格式('2018-12-12 10:10:10','%Y-%m') 哪个输出2018-12年 在普雷斯托或博士后,我如何才能做到这一点 我可以用它来做 concat(铸造(年份('2018-12-12 10:10:10')为varchar),'-',铸造(月份('2018-12-12 10:10:10')为varchar))为年份_月 但是看起来很麻烦。在Postgres上,我们

从datetime
2018-12-12 10:10:10
到仅获取年-月,我通常在MySQL8.0中这样做

date\u格式('2018-12-12 10:10:10','%Y-%m')

哪个输出2018-12年<代码>

在普雷斯托或博士后,我如何才能做到这一点

我可以用它来做

concat(铸造(年份('2018-12-12 10:10:10')为varchar),'-',铸造(月份('2018-12-12 10:10:10')为varchar))为年份_月


但是看起来很麻烦。

在Postgres上,我们可以使用
在这里添加字符:

选择作为dt的字符('2018-12-12 10:10:10'::时间戳,'YYYY-MM');
--2018-2012年产出
在presto中

日期\u格式(日期,%Y-%m')为年\u月

似乎有效