如何在 postgresql 中使用子字符串函数?

我试图在 postgresql 中使用 substring 函数,但错误是

'没有函数匹配给定的名称和参数类型。您可能需要添加显式类型转换。'

这是代码

select order_id,ship_date,Substring (ship_date from 5 for 2) as month
from tewt
order by ship_date;

对此的任何建议都会有所帮助。

w459537795 回答:如何在 postgresql 中使用子字符串函数?

如果 ship_date 是日期,则不要使用字符串函数。

从日期中提取月份的正确方法是使用 extract()

select order_id,ship_date,extract(month from ship_date) as month
from tewt
order by ship_date;
,

我弄错了,它是一个“字符串”,它不适用于数字。 感谢大家的帮助。

https://social.msdn.microsoft.com/Forums/sqlserver/en-US/c2161b80-ff96-4cac-91f2-21e30db7fcf0/is-there-a-function-like-substring-but-for-integers?forum=transactsql

本文链接:https://www.f2er.com/29203.html

大家都在问