UNIX_TIMESTAMP() does not exist in PostgreSQL

Found a bug? Tell us!!
Post Reply
ads
Regular
Posts: 93
Joined: Sun Oct 29, 2006 11:39 am

UNIX_TIMESTAMP() does not exist in PostgreSQL

Post 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;
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: UNIX_TIMESTAMP() does not exist in PostgreSQL

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
ads
Regular
Posts: 93
Joined: Sun Oct 29, 2006 11:39 am

Re: UNIX_TIMESTAMP() does not exist in PostgreSQL

Post by ads »

Good workaround ;-)
Post Reply