X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 7CFE39FB38C for ; Fri, 22 Sep 2006 11:18:25 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 72560-05 for ; Fri, 22 Sep 2006 11:18:16 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail.telefor.hu (mail.telefor.hu [193.68.53.97]) by postgresql.org (Postfix) with ESMTP id 326849FB350 for ; Fri, 22 Sep 2006 11:18:15 -0300 (ADT) Received: from telefor-server.int.telefor-new.hu (telefor-server.int.telefor-new.hu [10.0.20.100]) by mail.telefor.hu (Postfix) with ESMTP id DF3441C044; Fri, 22 Sep 2006 16:18:09 +0200 (CEST) Received: from [10.0.20.33] ([10.0.20.33]) by telefor-server.int.telefor-new.hu with Microsoft SMTPSVC(6.0.3790.1830); Fri, 22 Sep 2006 16:14:41 +0200 Message-ID: <4513EFD1.1010500@telefor.hu> Date: Fri, 22 Sep 2006 16:14:41 +0200 From: =?UTF-8?B?TWV6ZWkgWm9sdMOhbg==?= Organization: Telefor Kft. User-Agent: Thunderbird 1.5.0.7 (Windows/20060909) MIME-Version: 1.0 To: Ezequias Rodrigues da Rocha CC: pgsql-sql@postgresql.org Subject: Re: Group by minute References: <55c095e90609220652t356c8591u412046aed091a52f@mail.gmail.com> In-Reply-To: <55c095e90609220652t356c8591u412046aed091a52f@mail.gmail.com> Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit X-OriginalArrivalTime: 22 Sep 2006 14:14:41.0961 (UTC) FILETIME=[72658190:01C6DE51] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.305 tagged_above=0 required=5 tests=AWL, HTML_40_50, HTML_MESSAGE, MIME_HTML_ONLY X-Spam-Level: X-Archive-Number: 200609/154 X-Sequence-Number: 26365 Ezequias Rodrigues da Rocha wrote:
Hil list,

I have a query but my IDE (Delphi) does not accept "to_char" capability. Is there a way to reproduce the same query without using to_char function ?

Here is my query:
SELECT  to_char(quando,'dd/MM/yyyy HH24:MI'),count(id)
FROM base.tentativa
WHERE  (SESSAO_ID = 15)
GROUP BY to_char(quando,'dd/MM/yyyy HH24:MI')
order by 1

That seems like a valid query in Oracle :-)

Postgres have a slightly different mechanism for handling date and time. The modified query:

SELECT  date_trunc('minute', quando),count(id)
FROM base.tentativa
WHERE  (SESSAO_ID = 15)
-- GROUP BY to_char(quando,'dd/MM/yyyy HH24:MI')
GROUP BY date_trunc('minute', quando)
order by 1

You should read:
http://www.postgresql.org/docs/8.1/interactive/functions-datetime.html

Zizi