Re: Formating Dates

From: Ron St-Pierre <rstpierre(at)syscor(dot)com>
To: Colin Gillespie <C(dot)Gillespie(at)newcastle(dot)ac(dot)uk>, pgsql-novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Formating Dates
Date: 2004-04-06 15:00:40
Message-ID: 4072C618.2050706@syscor.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Colin Gillespie wrote:

>Dear All,
>
>I have table which has a column 'timestamp' and a default 'now()'. Using this method puts the date into table but includes upto milliseconds. How do I view only the date and time (not including seconds).
>
>For example 2004-03-30 09:46:36.904064 would become 2004-03-30 09:46:36
>
>Thanks
>
>Colin
>
>---------------------------(end of broadcast)---------------------------
>TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
>
>
>
>
Check out Section "6.7 Data Type Formatting Functions" of the manual for
all your options, but you would use something along the lines of :
select to_char(timestamp 'now','HH12:MI:SS');
to_char
----------
07:54:50
(1 row)

There are a lot of year, month and day formatting options eg(Y, YY, YYY,
YYY, Mon, etc etc), so you would add these formatting options to the
time ones eg:
select to_char(timestamp 'now','Y-Mon-DD HH12:MI:SS');
to_char
-------------------
4-Apr-06 08:00:22
(1 row)

hth

Ron

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Stephan Szabo 2004-04-06 15:09:23 Re: 7.4 dramatically slower than 7.3?
Previous Message Jeff Eckermann 2004-04-06 14:51:17 Re: Equivalent of MSSQL "PATINDEX" ?