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.
Author |
Topic |
drewsalem
Constraint Violating Yak Guru
304 Posts |
Posted - 2007-07-25 : 10:29:05
|
Hi,How do I prevent sql server from changing the format of a selected date when used with a string function i.e.If the column dateColumn contains 2007-07-01 10:00:00.000 thenSelect replace (datecolumn, '-','')from tablereturns:Jul 1 2007 10:00AMI want it to return 20070701 10:00:00.000 as it is in the column.ThanksDrewDrew---------------------"It's Saturday night; I've got no date, a two litre bottle of Shasta, and my all-Rush mix tape... LET'S ROCK." |
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2007-07-25 : 10:49:35
|
How about thisDECLARE @date smalldatetimeset @date = '2007-07-01 10:00:00.000'SELECT CONVERT(varchar(10),@Date,112)+' ' +CONVERT(varchar(20),@DATE,114)But this is varchar, not smalldatetimeJim |
 |
|
drewsalem
Constraint Violating Yak Guru
304 Posts |
Posted - 2007-07-25 : 11:01:29
|
That's great. Thanks.Drew---------------------"It's Saturday night; I've got no date, a two litre bottle of Shasta, and my all-Rush mix tape... LET'S ROCK." |
 |
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2007-07-25 : 12:24:58
|
select convert(varchar(8),getdate(),112) + ' ' + convert(varchar(12),getdate(),114)oops - guess I had that waiting for a response and went away.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|
|