Re: ask about epoch query with datetime

From: Ian Barwick <barwick(at)gmail(dot)com>
To: haries fajar nugroho <hariesfn(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: ask about epoch query with datetime
Date: 2009-05-07 08:47:03
Message-ID: 1d581afe0905070147x7a1fd526k75eb6bb683cf930d@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

2009/5/7 haries fajar nugroho <hariesfn(at)gmail(dot)com>:
> Hi All,
>
> my institution wants me to migrate from old postgresql to new
> postgresql, but when i test one of the query it failed at query :
> select date_part('epoch',datetime('2009-04-20
> 17:08:01')-datetime('2009-04-20 17:04:24'))::int;
> that query runs well in previous postgresql (PostgreSQL 7.1.3). The
> error message is ERROR:  function datetime("unknown") does not exist
> HINT:  No function matches the given name and argument types. You may
> need to add explicit type casts.
>
> If i read the error message, it means the function has changed or
> something. May  I know the latest function so my query can run well in
> my PostgreSQL 8.1.11 ?

Try something like:

select date_part('epoch','2009-04-20 17:08:01'::TIMESTAMP -
'2009-04-20 17:04:24'::TIMESTAMP)::int;

Ian Barwick

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Marc Mamin 2009-05-07 14:51:31 select regexp_matches('a a a', '([a-z]) a','g');
Previous Message haries fajar nugroho 2009-05-07 08:24:22 ask about epoch query with datetime