在 PostgreSQL 中将 YYY-MM-DD 转换为 MON DD, YYYY

发布于 2025-01-16 13:22:37 字数 263 浏览 1 评论 0原文

我在将列中的日期从 YYYY-MM-DD 转换为 Mon DD, YYYY 时遇到困难,

我想我首先需要重新组织日期,然后使用 case when 语句指定 01 = Jan 等?这是正确的吗?

SELECT to_date(column_name, 'MM/DD/YYYY') 
FROM table

给了我一些不正确的日期 即之前 = 2012-01-29 和 查询结果 = 0197-06-26

有什么建议吗?谢谢

I am having difficulty converting dates in a column from YYYY-MM-DD to Mon DD, YYYY

I think I first need to reorganize the dates and then use a case when statement to specify 01 = Jan and so on? Is that correct?

SELECT to_date(column_name, 'MM/DD/YYYY') 
FROM table

gives me some incorrect dates
i.e. previous = 2012-01-29 and
result from query = 0197-06-26

Any suggestions? Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

属性 2025-01-23 13:22:37

我想通了!

SELECT to_char(date(column_name), 'Mon dd, yyyy')
FROM table

给了我我所需要的东西,而不需要案例陈述。

I figured it out!

SELECT to_char(date(column_name), 'Mon dd, yyyy')
FROM table

gives me exactly what I need without the need of a case statement.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文