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 |
|
hydtohou
Starting Member
24 Posts |
Posted - 2007-10-19 : 11:10:46
|
| Hi , My requirement is to convert and send one datetime column from Stored Procedure in this format MM/DD/YYYY/HH:MM:SS right now I'm doing it in this fashionCONVERT(varchar(10),@today,101) + '/' + CONVERT(varchar(10),@today,108) Is there any other way where I can specify the style in which I can convert the datetime to whatever format I want.I know, I can do it in the C# code i.e., myDate.ToString("MM/dd/yyyy/hh:mm:ss");But I want to do this in TSQL,Any help is very much appreciated.Regards, |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2007-10-19 : 11:28:51
|
| What's wrong with what you have?There's no format string if that's what you're asking.Note the transfer format you are using is dangerous as it's ambiguous - at some someone will probably interpret it as dd/mm/yyyy==========================================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. |
 |
|
|
hydtohou
Starting Member
24 Posts |
Posted - 2007-10-19 : 11:46:54
|
| I'm not saying that there is anything wrong.But if I have to change the format as MM/DD/YYYY/HH/MM/SS How do I do that?I could change that in C# as myDate.ToString("MM/dd/yyyy/hh/mm/ss");The transfer format is defined in our system and I'm hopeful that there would be no ambiguous interpretation. |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2007-10-19 : 11:49:14
|
| Just change the : to /replace(CONVERT(varchar(10),@today,101) + '/' + CONVERT(varchar(10),@today,108), ':', '/')orCONVERT(varchar(10),@today,101) + '/' + replace(CONVERT(varchar(10),@today,108), ':', '/')==========================================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. |
 |
|
|
hydtohou
Starting Member
24 Posts |
Posted - 2007-10-19 : 11:51:24
|
| good one thanks a lot |
 |
|
|
|
|
|
|
|