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 |
|
moodi_z
Starting Member
38 Posts |
Posted - 2009-08-23 : 10:03:29
|
| Hi,I'm geting a date from xml file that my sp gets as a parameter.. I dont know in wich format the date will be sent and I want my sp to handle all formates by converting to one format that I choosed to work with "dmy".In one example the date is written like this: Jul-20-2009 15:45isdate on it returns 0. converting by using: convert(datetime,'jul-15-2009 15:30:00',103) also falls, but convert(datetime,'15-jul-2009 15:30:00',103) do works!Is it related on my sql server definitions?! how can I write a code that works never mind whatever the server definitions are!Thanks in advance. |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-08-23 : 15:08:47
|
[code]DECLARE @Data VARCHAR(30)SET @Data = 'Jul-20-2009 15:45'SELECT CONVERT(DATETIME, REPLACE(@Data, '-', ' '), 107)[/code] N 56°04'39.26"E 12°55'05.63" |
 |
|
|
moodi_z
Starting Member
38 Posts |
Posted - 2009-08-24 : 01:03:17
|
| OK, thanks. |
 |
|
|
Nageswar9
Aged Yak Warrior
600 Posts |
|
|
|
|
|