Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 I want to get time values from a datetime value

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-10-05 : 07:22:26
Murugesh writes "Hi,
I want to get only the time values from a datetime value.
Say for eg: if datetime value is '1/2/2005 1:02:23 AM',
I just want to get only '1:02:23 AM' from the above date. Is there anyfunction, i can use or could anyone help me out to fix this?

Lots of thanks,
T.Murugesh Babu"

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-10-05 : 07:32:39
If it is only for Disply purpose then

select Convert(varchar,getdate(),8)

Otherwise use Format function in your Front End Application

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2005-10-05 : 07:32:48
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=55982


Duane.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-10-05 : 07:55:27
quote:
Originally posted by ditch

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=55982


Duane.


ditch, I think that link is not the solution for this question

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2005-10-05 : 08:04:30
why not?
it was first converting a float to date time and then extracting the time portion.


Duane.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-10-05 : 08:54:15
I think select Convert(varchar,getdate(),8) is enough

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2005-10-05 : 08:57:32
It is.
But it can't display the milliseconds

Duane.
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2005-10-05 : 11:10:04
If you have to show the the milliseconds:

select [time]=right(convert(varchar(30),getdate(),121),12)

time
---------------
11:10:39.793




CODO ERGO SUM
Go to Top of Page

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2005-10-05 : 11:19:16
quote:
Originally posted by Michael Valentine Jones

If you have to show the the milliseconds:

select [time]=right(convert(varchar(30),getdate(),121),12)

time
---------------
11:10:39.793




CODO ERGO SUM



NICE

Duane.
Go to Top of Page
   

- Advertisement -