Re: Formating Dates - Mailing list pgsql-novice

From Ron St-Pierre
Subject Re: Formating Dates
Date
Msg-id 4072C618.2050706@syscor.com
Whole thread Raw
In response to Formating Dates  ("Colin Gillespie" <C.Gillespie@newcastle.ac.uk>)
List 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 by date:

Previous
From: Jeff Eckermann
Date:
Subject: Re: Equivalent of MSSQL "PATINDEX" ?
Next
From: Stephan Szabo
Date:
Subject: Re: 7.4 dramatically slower than 7.3?