Re: to_timestamp alternatives - Mailing list pgsql-general

From Jim Nasby
Subject Re: to_timestamp alternatives
Date
Msg-id 568C7A5D.1050605@BlueTreble.com
Whole thread Raw
In response to Re: to_timestamp alternatives  (Thomas Kellerer <spam_eater@gmx.net>)
List pgsql-general
On 1/1/16 4:11 AM, Thomas Kellerer wrote:
> You only need to provide the text value to be casted (no format mask).
> Use only a single expression without those unnecessary parentheses:
>
>      SELECT gmt_date||' '||lpad(gmt_time,8,'0')::timestamp
>
> You don't need the lpad() either:
>
>      SELECT gmt_date||' '||gmt_time::timestamp

I suspect you need to wrap that in (). Even if the parser does the right
thing there, it'd certainly make the intent a lot clearer.

SELECT (gmt_date || ' ' || gmt_time)::timestamp
--
Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX
Experts in Analytics, Data Architecture and PostgreSQL
Data in Trouble? Get it in Treble! http://BlueTreble.com


pgsql-general by date:

Previous
From: Jim Nasby
Date:
Subject: Re: Getting the function definition from oid in before firing the function
Next
From: Jim Nasby
Date:
Subject: Re: COPY FROM STDIN