SQL Server Forums
Profile | Register | 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
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

anupalavila
Yak Posting Veteran

55 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

55 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

55 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
52249 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  
 New 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.06 seconds. Powered By: Snitz Forums 2000