[erlang-questions] timestamp for pgsql

Daniel Caune <>
Wed Dec 5 14:41:28 CET 2007

>In the current postgresql driver for erlang (I'm using the
ejabberd-module >one because that's the one I got to work), how does one
specify TIMESTAMP >values?
>ie if I do
>pgsql:prepare(Db, my_insert, "insert into foo_table (timestamp_column)
>values ($1)"). 
>what should I put in the subsequent call to 
>pgsql:execute(Db, my_insert, [?????])

You should be able to write something like this:

pgsql:prepare(Db, my_insert, "insert into foo_table (timestamp_column)
values ($1::timestamp)"). 
pgsql:execute(Db, my_insert, ["YYYY-MM-DD HH24:MN:SS"]).

I'm not sure that "::timestamp" is very useful as I suppose PostgreSQL
to do the conversion by its own.

>P.S. I think the Junglerl pgsql driver is broken for prepared

Did you try pgsql:pquery?  It works fine.


More information about the erlang-questions mailing list