By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,372 Members | 1,906 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,372 IT Pros & Developers. It's quick & easy.

Getting time from date field

P: n/a
Hi !

Is there any way to get the time like the following example ?

'2003-05-11 15:21:21'

should return

'15:21:21'
Thanks !!

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Wed, Nov 05, 2003 at 17:12:12 +0000,
Alejandro Javier Pomeraniec <ap*********@buenosaires.gov.ar> wrote:
Hi !

Is there any way to get the time like the following example ?

'2003-05-11 15:21:21'

should return

'15:21:21'


You can use the to_char function to convert timestamps to text with
control over the output format.

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 12 '05 #2

P: n/a
On Wed, Nov 05, 2003 at 05:12:12PM +0000, Alejandro Javier Pomeraniec wrote:
Is there any way to get the time like the following example ?

'2003-05-11 15:21:21'

should return

'15:21:21'


Cast it to time:

regression=# SELECT '2003-05-11 15:21:21'::time;
time
----------
15:21:21
(1 fila)

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"No necesitamos banderas
No reconocemos fronteras" (Jorge González)

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.