Re: Extract date from a TIMESTAMP(6) WITHOUT TIME ZONE NOT NULL column

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Patrick B <patrickbakerbr(at)gmail(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Extract date from a TIMESTAMP(6) WITHOUT TIME ZONE NOT NULL column
Date: 2016-09-22 04:08:27
Message-ID: e9014508-64e8-f00b-f1e4-e282d74b5dec@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 09/21/2016 08:37 PM, Patrick B wrote:
> Hi guys,
>
> I'm using postgres 9.2 and got the following column:
>
> start TIMESTAMP(6) WITHOUT TIME ZONE NOT NULL
>
>
> SELECT start FROM test1;
>
>
> 2015-12-18 02:40:00
>
> I need to split that date into two columns on my select:
>
> 2015-12-18 = date column
> 02:40:00 = time column
>
> How can I do that without modifying any column/data?
> Maybe in a select?

test=# select
'2015-12-18 02:40:00'::date,
'2015-12-18 02:40:00'::timestamp - '2015-12-18 02:40:00'::date AS time_val;

date | time_val
------------+----------
2015-12-18 | 02:40:00

>
> Thanks!
> Patrick

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message John R Pierce 2016-09-22 04:14:42 Re: Extract date from a TIMESTAMP(6) WITHOUT TIME ZONE NOT NULL column
Previous Message Venkata B Nagothi 2016-09-22 04:01:14 Re: Extract date from a TIMESTAMP(6) WITHOUT TIME ZONE NOT NULL column