gpt4 book ai didi

sql - YEAR 给出错误

转载 作者:行者123 更新时间:2023-12-04 02:21:03 25 4
gpt4 key购买 nike

pgAdmin III 总是给出错误的年份

ERROR: function year(date) does not exist LINE 1: SELECT YEAR(geboortedatum) as date_part .............................^^^^.........

HINT: No function matches the given name and argument types. You might need to add explicit type casts. ********** Error **********

ERROR: function year(date) does not exist SQL state: 42883
Hint: No function matches the given name and argument types. You might need to add explicit type casts.
Character: 8

我可以获得我需要的整个日期,但我只需要年份,有人可以帮助我,它需要是表格中最年轻的年份。

最佳答案

正如您提到的 pgAdmin,我假设您使用的是 Postgres,因此您需要编写如下代码(使用 EXTRACT 构造):

SELECT EXTRACT(YEAR FROM TIMESTAMP '2001-02-16 20:38:40');

Detailed documentation for the datetime functions

关于sql - YEAR 给出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29494927/

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