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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Get hour part only from datetime
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

anupalavila
Yak Posting Veteran

56 Posts

Posted - 09/27/2008 :  06:03:48  Show Profile  Reply with Quote

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
Flowing Fount of Yak Knowledge

Nigeria
2706 Posts

Posted - 09/27/2008 :  06:14:07  Show Profile  Reply with Quote
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 - 09/27/2008 :  06:16:32  Show Profile  Reply with Quote
I mean to return the hour part

Thanks and Regards
Anu Palavila
Go to Top of Page

afrika
Flowing Fount of Yak Knowledge

Nigeria
2706 Posts

Posted - 09/27/2008 :  06:20:28  Show Profile  Reply with Quote
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 - 09/27/2008 :  06:39:10  Show Profile  Reply with Quote

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

India
52326 Posts

Posted - 09/27/2008 :  06:57:24  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000