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 

sanjay5219
Posting Yak Master

240 Posts

Posted - 2010-06-26 : 10:13:34
Dear All,

I have a value in table 1900-01-01 02:02.00.000.I want to show this value like 02:02. Please provide me query for this.

Thanks,

Sanjay

Sachin.Nand

2937 Posts

Posted - 2010-06-26 : 10:27:12
declare @dt as datetime='1900-01-01 02:02:00:000'
select convert(varchar(5),@dt,108)


Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless.

PBUH
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-06-28 : 03:12:02
If you use front end application, do the formation there

Madhivanan

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

senthil_nagore
Master Smack Fu Yak Hacker

1007 Posts

Posted - 2010-06-28 : 03:17:24
quote:
Originally posted by Idera

declare @dt as datetime='1900-01-01 02:02:00:000'
select convert(varchar(5),@dt,108)


Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless.

PBUH



Hi Idera,

I got the error, while execute your statement!


Msg 139, Level 15, State 1, Line 0
Cannot assign a default value to a local variable.

It might be

declare @dt as datetime
Set @dt='1900-01-01 02:02:00:000'
select convert(varchar(5),@dt,108)



Senthil.C
------------------------------------------------------
[Microsoft][ODBC SQL Server Driver]Operation canceled

http://senthilnagore.blogspot.com/
Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2010-06-28 : 03:28:03
quote:
Originally posted by senthil_nagore

quote:
Originally posted by Idera

declare @dt as datetime='1900-01-01 02:02:00:000'
select convert(varchar(5),@dt,108)


Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless.

PBUH



Hi Idera,

I got the error, while execute your statement!


Msg 139, Level 15, State 1, Line 0
Cannot assign a default value to a local variable.

It might be

declare @dt as datetime
Set @dt='1900-01-01 02:02:00:000'
select convert(varchar(5),@dt,108)



Senthil.C
------------------------------------------------------
[Microsoft][ODBC SQL Server Driver]Operation canceled

http://senthilnagore.blogspot.com/




Hi,

Because you are using SQL Server 2005 while I am using 2008.


Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless.

PBUH
Go to Top of Page

senthil_nagore
Master Smack Fu Yak Hacker

1007 Posts

Posted - 2010-06-28 : 04:41:31
quote:
Originally posted by Idera

quote:
Originally posted by senthil_nagore

quote:
Originally posted by Idera

declare @dt as datetime='1900-01-01 02:02:00:000'
select convert(varchar(5),@dt,108)


Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless.

PBUH



Hi Idera,

I got the error, while execute your statement!


Msg 139, Level 15, State 1, Line 0
Cannot assign a default value to a local variable.

It might be

declare @dt as datetime
Set @dt='1900-01-01 02:02:00:000'
select convert(varchar(5),@dt,108)



Senthil.C
------------------------------------------------------
[Microsoft][ODBC SQL Server Driver]Operation canceled

http://senthilnagore.blogspot.com/




Hi,

Because you are using SQL Server 2005 while I am using 2008.


Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless.

PBUH



Ya, thank you so much

Senthil.C
------------------------------------------------------
[Microsoft][ODBC SQL Server Driver]Operation canceled

http://senthilnagore.blogspot.com/
Go to Top of Page
   

- Advertisement -