x

Function to extract only time from a date object?

Trunc() funciton is to get date part without time from a date object. Is there any function to get Time part of the date object?

more ▼

asked Dec 16, 2009 at 02:20 PM in Default

avatar image

dbkid
131 9 10 14

(comments are locked)
10|1200 characters needed characters left

2 answers: sort voted first

Use TO_CHAR(date,"<format>")

e.g.:

SELECT TO_CHAR(sysdate,"HH:MI:SS")
more ▼

answered Dec 16, 2009 at 02:28 PM

avatar image

Andrew Mobbs
1.6k 3 5

Thanks a lot Andrew! Now I am able to extract time. But I have question, don't we have a function like Trunc() to get time part? Here do we need to use TO_CHAR() ? Thanks once again.

Dec 16, 2009 at 02:30 PM dbkid

Thank you Andrew.

Dec 16, 2009 at 02:58 PM dbkid

Sorry - the stuff I wrote about TRUNC() and strings was rubbish... its been a long day. I meant of course TRUNC() and numbers.

Dec 16, 2009 at 03:10 PM Andrew Mobbs
(comments are locked)
10|1200 characters needed characters left

You can use extract() function also.

more on this web page

more ▼

answered Dec 16, 2009 at 02:34 PM

avatar image

Tariq Rahiman
665 2 4 7

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x1016
x426

asked: Dec 16, 2009 at 02:20 PM

Seen: 1410 times

Last Updated: Dec 18, 2009 at 02:49 AM

Copyright 2016 Redgate Software. Privacy Policy