提取命令在mysql中返回null ..请有什么建议吗?
我正在尝试从订单_date从名为warehouse.big_w_orders中获取年。 order_date包含一个日期格式,例如1/1/2019,但数据类型是文本。当我在下面编写查询时,只是返回“ null'而不是2019年。我尝试使用铸件将数据类型更改为迄今为止甚至浮动,但也没有起作用。
从warehouse.big_w_orders中选择提取物(从order_date的年);
有人可以在这里帮我吗?先感谢您!
I'm trying to pull year from order_Date from the table called warehouse.big_w_orders. order_date contains a date format such as 1/1/2019 but the data type is text. When I write the query below it just returns 'null' not 2019. I tried to use CAST fuction to change the data type to date or even float but it didn't work either.
SELECT extract(year from order_date) FROM warehouse.big_w_orders;
Could someone please help me out here? Thank you in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如您所说,
order_date
的数据类型是文本。因此,从技术上讲,您不能从文本中提取年。您需要先将文本转换为日期。尝试以下操作:
As you said, the data type of
order_date
is text. So technically, you cannot extract year from text. You need to convert your text to a date first.Try this: