我试图在 postgresql 中使用 substring 函数,但错误是
'没有函数匹配给定的名称和参数类型。您可能需要添加显式类型转换。'
这是代码
select order_id,ship_date,Substring (ship_date from 5 for 2) as month
from tewt
order by ship_date;
对此的任何建议都会有所帮助。
我试图在 postgresql 中使用 substring 函数,但错误是
'没有函数匹配给定的名称和参数类型。您可能需要添加显式类型转换。'
这是代码
select order_id,ship_date,Substring (ship_date from 5 for 2) as month
from tewt
order by ship_date;
对此的任何建议都会有所帮助。
如果 ship_date
是日期,则不要使用字符串函数。
从日期中提取月份的正确方法是使用 extract()
:
select order_id,ship_date,extract(month from ship_date) as month
from tewt
order by ship_date;
,
我弄错了,它是一个“字符串”,它不适用于数字。 感谢大家的帮助。