Datetime format change the number of returned rows in PostgreSQL

时间:2016-02-03 04:23:57

标签: postgresql date-format

I really dont get this...

This first statement below returns the expected rows - ONLY rows which have a date which are BEFORE/SMALLER than...

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

The code below return rows with dates up to the 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: I use PostgresSQL, NodeJS and NPM Moment...BUT the result is from the PostgreSQL tool pgAminIII...so - it has nothing to do with my own code...!

matchdate in the DB is a "datetime with time zone" like:

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

1 个答案:

答案 0 :(得分:0)

PostgreSQL不了解格式Sat Jan 17 2015 00:00:00 GMT+0100的日期,但它可能会尽力而为。以下是它确实理解的datestime格式的表格。 A complete explanation can be found here

您必须将Sat Jan 17 2015 00:00:00 GMT+0100转换为Postgres理解的格式。它非常接近the HTTP date format