Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
[code]DECLARE @var datetime='2004-11-04 00:00:00.000'Method 1 :SELECT CONVERT (VARCHAR(10),@var, 101) +' '+ cast(cast(@var AS time) AS varchar(100))Method 2 : SELECT replace(convert(varchar, @var, 111), '', '/') +' '+cast(CAST(@var AS time) as varchar(max))[/code]---------------Murali KrishnaYou live only once ..If you do it right once is enough.......
dr223
Constraint Violating Yak Guru
444 Posts
Posted - 2014-12-03 : 09:30:46
Both suggestions provide the output as
11/04/2004 00:00:00.0000000
Shouldn't this be
11/04/2004 00:00:00:000
instead.Thanks
gbritton
Master Smack Fu Yak Hacker
2780 Posts
Posted - 2014-12-03 : 09:43:35
just chop off the extra zeros with a LEFT() function call!
gbritton
Master Smack Fu Yak Hacker
2780 Posts
Posted - 2014-12-03 : 09:43:43
just chop off the extra zeros with a LEFT() function call!