Formating Dates
Formating Dates
От:
"Colin Gillespie" <C.Gillespie@newcastle.ac.uk>
Дата:
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
Re: Formating Dates
От:
Ron St-Pierre <rstpierre@syscor.com>
Дата:
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@postgresql.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