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

标签 postgresql date-format

我真的不明白这个...

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

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/

相关文章:

python - Django 1.8 ArrayField 追加和扩展

ruby-on-rails - 加速 pg_search 中使用关联的查询

postgresql - Postgres - 使用嵌套数组和数组内的对象查询 json

java - 如何使用日历生成开始和结束时间?

javascript Regex 日期早于 1970 年 1 月 1 日

javascript - 如何使用 Sequelize 建立关系

postgresql - 刷新物化 View 同时导致表膨胀

php - 时间如何储存

mysql - 如何使用 mysql date_format 动态给出日期?

php - date_format PHP 使用 mySQL 调用