Re: Error in crosstab using date_trunc - Mailing list pgsql-general

From José María Terry Jiménez
Subject Re: Error in crosstab using date_trunc
Date
Msg-id 4B1B9A59.6000104@tssystems.net
Whole thread Raw
In response to Re: Error in crosstab using date_trunc  (Richard Broersma <richard.broersma@gmail.com>)
List pgsql-general
Richard Broersma escribió:
> On Sat, Dec 5, 2009 at 11:11 AM, Jose Maria Terry Jimenez
> <jtj@tssystems.net> wrote:
>
>
>> select distinct date_trunc('minute',"timestamp") as "timestamp" from
>> historico order by "timestamp";
>>
>
> Notice the example from the documentation:
> http://www.postgresql.org/docs/8.4/interactive/functions-datetime.html#FUNCTIONS-DATETIME-TRUNC
>
> SELECT date_trunc('hour', TIMESTAMP '2001-02-16 20:38:40');
> Result: 2001-02-16 20:00:00
>
>
> In this case the keyword the second argument of the date_trunc() function is:
>
> TIMESTAMP '2001-02-16 20:38:40'
>
> This text is a special kind of cast that exists for time based datatypes.
>
> This could be re-written as:
>
> CAST( '2001-02-16 20:38:40' AS TIMESTAMP)
> or
>  '2001-02-16 20:38:40'::TIMESTAMP
>
> Other examples would be:
>
> SELECT date_trunc( 'hour', now())
>
> or
>
> SELECT date_trunc( 'hour', myTimestampColumn)
>   FROM MyTable
> LIMIT 1;
>
> I hope this helps.
>
>
>
Thanks you by your answer, but the problem is date_func didn't worked in
a crosstab query. It is solved by escaping with two ' the keyword minute
' 'minute' ' as others reply me.

Best,
Jose Maria

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Scanned with Copfilter Version 0.84beta3a (ProxSMTP 1.6)
AntiVirus: ClamAV 0.95.2/10114 - Fri Dec  4 23:54:13 2009
by Markus Madlener @ http://www.copfilter.org

pgsql-general by date:

Previous
From: Wolfgang Keller
Date:
Subject: postgresql_autodoc in Python?
Next
From: José María Terry Jiménez
Date:
Subject: Re: Error in crosstab using date_trunc