Re: Formating Dates

Поиск
Список
Период
Сортировка
От Ron St-Pierre
Тема Re: Formating Dates
Дата
Msg-id 4072C618.2050706@syscor.com
обсуждение исходный текст
Ответ на Formating Dates  ("Colin Gillespie" <C.Gillespie@newcastle.ac.uk>)
Список 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
includesupto 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


В списке pgsql-novice по дате отправления:

Предыдущее
От: Jeff Eckermann
Дата:
Сообщение: Re: Equivalent of MSSQL "PATINDEX" ?
Следующее
От: Stephan Szabo
Дата:
Сообщение: Re: 7.4 dramatically slower than 7.3?