Page 1 of 1

UNIX_TIMESTAMP() does not exist in PostgreSQL

Posted: Sun Mar 28, 2010 3:20 pm
by ads
Hello,

i get the following error in my database logfile:

Code: Select all

2010-03-28 15:14:39 CEST ERROR:  function unix_timestamp(timestamp with time zone) does not exist at character 199
2010-03-28 15:14:39 CEST HINT:  No function matches the given name and argument types. You may need to add explicit type casts.
2010-03-28 15:14:39 CEST STATEMENT:  SELECT * FROM serendipity_entryproperties WHERE property LIKE 'mf_hCalendar_%' AND entryid IN (SELECT entryid FROM serendipity_entryproperties WHERE property = 'mf_hCalendar_startdate' AND value > (UNIX_TIMESTAMP(NOW()) - 259200))
In PostgreSQL one can get the current unix time with the following syntax:

Code: Select all

SELECT (EXTRACT(EPOCH FROM NOW()) - 259200)::INT;

Re: UNIX_TIMESTAMP() does not exist in PostgreSQL

Posted: Mon Mar 29, 2010 9:38 am
by garvinhicking
Hi!

Thanks for mentioning this. I just committed a fix to the plugin that uses PHP native time() function to extract a current timestamp, which should hopefully work accross all DBs.

Regards,
Garvin

Re: UNIX_TIMESTAMP() does not exist in PostgreSQL

Posted: Mon Mar 29, 2010 12:32 pm
by ads
Good workaround ;-)