gpt4 book ai didi

postgresql - 日期时间格式更改 PostgreSQL 中返回的行数

转载 作者:行者123 更新时间:2023-11-29 13:54:18 25 4
gpt4 key购买 nike

我真的不明白这个...

下面的第一条语句返回预期的行 - 只有日期早于/小于...的行

select matchdate, price, size, issell from matchmsg 
where matchdate <= '2015-01-17 00:00:00.000000+01' order by matchdate asc

下面的代码返回日期为 2015-01-21...!?

select matchdate, price, size, issell from matchmsg 
where matchdate <= 'Sat Jan 17 2015 00:00:00 GMT+0100' order by matchdate asc

PS:我使用 PostgresSQL、NodeJS 和 NPM Moment...但结果来自 PostgreSQL 工具 pgAminIII...所以 - 它与我自己的代码无关...!

数据库中的匹配日期是“带时区的日期时间”,例如:

"2015-01-16 00:00:22.491956+01"

最佳答案

PostgreSQL 不理解格式为 Sat Jan 17 2015 00:00:00 GMT+0100 的日期,但它可能正在尽力而为。这是 dates 的表格和 time它确实理解的格式。 A complete explanation can be found here .

您必须将 Sat Jan 17 2015 00:00:00 GMT+0100 转换为 Postgres 可以理解的格式。离the HTTP date format很近.

关于postgresql - 日期时间格式更改 PostgreSQL 中返回的行数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35168490/

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