M
M
McMike2016-12-09 07:49:47
PostgreSQL
McMike, 2016-12-09 07:49:47

How to compare dates in different formats in Yii2-Postgresql?

You need to compare dates in different formats in the query. If you make a simple query, then you can use TIMESTAMP in pg, but if you collect a query from the framework, then the TIMESTAMP operator is escaped:
("table"."value::timestamp" = '1980-09-27::timestamp') or " TIMESTAMP table"."value" = 'TIMESTAMP 1980-09-27'
How to deal with this?
Functions (like CAST) are not escaped, they work normally. Can I somehow tell yii that TIMESTAMP is an operator and should not be merged with a string?
Or some analogue of TIMESTAMP on the side of the database, but in the form of a function?
Or the function of casting to some format

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
krypt3r, 2016-12-09
@krypt3r

Have a look at the to_timestamp() function

M
McMike, 2016-12-09
@McMike

The problem was solved by assembling the condition manually, and not from an array.
For academic purposes, I'll leave the question open for now.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question