Select date & time

From: Jan Danielsson <jan(dot)danielsson(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Select date & time
Date: 2006-02-04 18:32:59
Message-ID: 43E4F35B.70004@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hello,

I have a table in which I have three columns (for reasons I will not
go into here): Date, time and time (milliseconds). However, I want to
start using timestamps instead. Problem is, I don't know how to get the
data in a proper format using selects.

Say I have a table:

> create table foo (ts timestamp)

..and I insert an entry:

> insert into table foo (ts) VALUES (now())

This will yield an entry which looks something like:

ts
---------------------------
2006-02-04 19:27:31.123456

I'm interested in retaining this information in the database, but not
when I'm going to present it. I.e. I want to be able to create a query
that will return:

date | time |
-----------+----------+----
2006-02-04 | 19:27:31 |

I figured out the date part:

> select date(ts) from foo

But how do I get the "time" part? Thankful for any tips.

--
Kind Regards,
Jan Danielsson
Te audire non possum. Musa sapientum fixa est in aure.

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Devrim GUNDUZ 2006-02-04 18:38:06 Re: createdb: could not connect to database
Previous Message Paul Smith 2006-02-04 17:56:28 Re: createdb: could not connect to database