Search Postgresql Archives

Re: pg_query_params() problem with date_trunc() (possibly other functions as well)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



patrick keshishian <pkeshish@xxxxxxxxx> writes:
> I started to look into using pg_query_params() with some
> php scripts, but ran into this issue where I get:

> PHP message: PHP Warning: pg_query_params(): Query failed: ERROR:
> invalid input syntax for type timestamp: "$1"
> LINE 1: ... date_trunc('day', now()), date_trunc('day', TIMESTAMP '$1')

You probably want just this:

... date_trunc('day', now()), date_trunc('day', $1)

or if that doesn't work, try this:

... date_trunc('day', now()), date_trunc('day', $1::timestamp)

The syntax TIMESTAMP '...' is only for plain literal constants.

			regards, tom lane



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux