gpt4 book ai didi

sql - 如何在不使用 to_char() 函数的情况下从 PostgreSQL 中的日期中提取年份和月份?

转载 作者:行者123 更新时间:2023-11-29 11:04:48 24 4
gpt4 key购买 nike

我要选择sql:SELECT "year-month"from table group by "year-month"AND order by date,其中年月 - 日期“1978-01”、“1923-12”的格式。选择 to_char of couse work,但不是“正确的”顺序:

to_char(timestamp_column, 'YYYY-MM')

最佳答案

to_char(timestamp, 'YYYY-MM')

你说顺序不“正确”,但我不明白为什么它是错误的(至少在 10000 年到来之前)。

关于sql - 如何在不使用 to_char() 函数的情况下从 PostgreSQL 中的日期中提取年份和月份?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4531577/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com