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

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Andreas Kretschmer <akretschmer(at)spamfence(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Joining dates/times (was Re: Splitting Timestamps)
Date: 2006-07-30 10:20:41
Message-ID: 20060730102041.GA14913@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sun, Jul 30, 2006 at 10:00:30AM +0200, Andreas Kretschmer wrote:
> 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 the easy way:

select '2006/07/29'::date + '10:00:00'::time;

No need to do anything odd at all...

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Flemming Frandsen 2006-07-30 10:24:24 Re: Performance of the listen command
Previous Message Andreas Kretschmer 2006-07-30 08:00:30 Re: Joining dates/times (was Re: Splitting Timestamps)