x
login about faq Site discussion (meta-askssc)

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 '09 at 02:20 PM in Default

dbkid gravatar image

dbkid
131 3 8 10

(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 '09 at 02:28 PM

Andrew Mobbs gravatar image

Andrew Mobbs
1.5k 1 3

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 '09 at 02:30 PM dbkid

Thank you Andrew.

Dec 16 '09 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 '09 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 '09 at 02:34 PM

Tariq Rahiman gravatar image

Tariq Rahiman
665 1 2 4

(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



Facebook logo Follow Ask SSC on Facebook
Find Ask SSC on Google+
linkedin logo Find us on LinkedIn

Topics:

x598
x359

asked: Dec 16 '09 at 02:20 PM

Seen: 584 times

Last Updated: Dec 18 '09 at 02:49 AM

Copyright © 2002-2012 Simple Talk Publishing. All Rights Reserved. If you have any queries, please contact the site administrators.
Ask SQL Server Central is a community service provided by Red Gate.