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)
 Get hour part only from datetime

Author  Topic 

anupalavila
Yak Posting Veteran

56 Posts

Posted - 2008-09-27 : 06:03:48

Hai,
what query can I use to get the hour part from the datetime 2008-09-27 09:30:00.000 so that the query returns 9


Thanks and Regards
Anu Palavila

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2008-09-27 : 06:14:07
Use datepart function.

when you say 9, what do you mean ? month or hour ?
Go to Top of Page

anupalavila
Yak Posting Veteran

56 Posts

Posted - 2008-09-27 : 06:16:32
I mean to return the hour part

Thanks and Regards
Anu Palavila
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2008-09-27 : 06:20:28
SELECT DATEPART(hour, '2008-09-27 09:30:00.000')

http://msdn.microsoft.com/en-us/library/ms174420.aspx
Go to Top of Page

anupalavila
Yak Posting Veteran

56 Posts

Posted - 2008-09-27 : 06:39:10

Thankyou very much Afrik for your valuable answer

Thanks and Regards
Anu Palavila
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-27 : 06:57:24
Did you refer links i posted for your other article. It contains all these info

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=111519
Go to Top of Page
   

- Advertisement -