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
 General SQL Server Forums
 New to SQL Server Programming
 Time Format

Author  Topic 

shemayb
Posting Yak Master

159 Posts

Posted - 2008-09-23 : 23:00:29
Hi!
Given: Date = 11/10/2005 06:30:00

How do i get the hour and minute value in the above given?

Funnyfrog

jobejufranz
Starting Member

33 Posts

Posted - 2008-09-24 : 00:41:26
quote:
Originally posted by shemayb

Hi!
Given: Date = 11/10/2005 06:30:00

How do i get the hour and minute value in the above given?

Funnyfrog



CONVERT(VARCHAR,Date,108)

If you want to display the result in front-end, I suggest you format the result in front-end and not on your query.

Cheers..
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-09-24 : 00:42:44
if you want the hour & minute separately, use datepart() function


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

shemayb
Posting Yak Master

159 Posts

Posted - 2008-09-24 : 00:52:15
If I want the outpu to be 0630? How will i do that?

Funnyfrog
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-09-24 : 01:07:26
You should use your Front End application to format the time accordingly

or

in SQL
replace(convert(varchar(5), Date, 108), ':', '')


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

shemayb
Posting Yak Master

159 Posts

Posted - 2008-09-24 : 02:05:24
now i got it..Thank you so much!:)

Funnyfrog
Go to Top of Page
   

- Advertisement -