Re: Joining dates/times (was Re: Splitting Timestamps)

From: Andreas Kretschmer <akretschmer(at)spamfence(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Joining dates/times (was Re: Splitting Timestamps)
Date: 2006-07-30 08:00:30
Message-ID: 20060730080030.GA32129@KanotixBox
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Ron Johnson <ron(dot)l(dot)johnson(at)cox(dot)net> schrieb:
> >> I know I can do a select to_date(now(),'yyyy-mm-dd') and it will return the
> >> date. However, how do I get the time? Also, is this the proper way to get
> >> the date portion of a timestamp?
> >
> > select now()::timetz;
> > select now()::time;
> > select now()::date;
>
> What's the inverse? Say I have a DATE and a TIME, and want to
> create a TIMESTAMP with them?

You can CAST it:

test=# select '2006/07/29 10:00:00'::timestamp;
timestamp
---------------------
2006-07-29 10:00:00
(1 row)

or:

test=# select ('2006/07/29'::date || ' ' || '10:00:00'::time)::timestamp;
timestamp
---------------------
2006-07-29 10:00:00
(1 row)

HTH, Andreas
--
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect. (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly." (unknow)
Kaufbach, Saxony, Germany, Europe. N 51.05082°, E 13.56889°

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2006-07-30 10:20:41 Re: Joining dates/times (was Re: Splitting Timestamps)
Previous Message Ron Johnson 2006-07-30 07:46:16 Joining dates/times (was Re: Splitting Timestamps)