Folks
what's wrong with
CONVERT(DATETIME, '20060405 14:45:43', 102)
I get the error "Syntax error converting datetime from character
string."
I was under the impression that the syntax YYYYMMDD HH:MM:SS was not
SET DATEFORMAT dependent, not SET LANGUAGE dependent and language
neutral... or, in other words, safe to use... ;)
Probably missing something obvious but can't figure it out.
Any info welcome
Regards
--alexTI have no problem running this whole block of code below
set dateformat mdy
select CONVERT(DATETIME, '20060405 14:45:43', 102)
go
set dateformat dmy
select CONVERT(DATETIME, '20060405 14:45:43', 102)
go
set dateformat ymd
select CONVERT(DATETIME, '20060405 14:45:43', 102)
go
set dateformat ydm
select CONVERT(DATETIME, '20060405 14:45:43', 102)
go
set dateformat myd
select CONVERT(DATETIME, '20060405 14:45:43', 102)
go
set dateformat dym
select CONVERT(DATETIME, '20060405 14:45:43', 102)
go
2006-04-05 14:45:43.000 is returned for every select
Denis the SQL Menace
http://sqlservercode.blogspot.com/|||I also tried SET LANGUAGE with various languages, Francais, Arabic, Svenska,
Espaol, Norsk, '?, British, latvieu, Suomi, etc. etc. I could not
get it to fail.
"SQL" <denis.gobo@.gmail.com> wrote in message
news:1144242672.204929.291270@.i39g2000cwa.googlegroups.com...
>I have no problem running this whole block of code below
> set dateformat mdy
> select CONVERT(DATETIME, '20060405 14:45:43', 102)
> go
> set dateformat dmy
> select CONVERT(DATETIME, '20060405 14:45:43', 102)
> go
> set dateformat ymd
> select CONVERT(DATETIME, '20060405 14:45:43', 102)
> go
> set dateformat ydm
> select CONVERT(DATETIME, '20060405 14:45:43', 102)
> go
> set dateformat myd
> select CONVERT(DATETIME, '20060405 14:45:43', 102)
> go
> set dateformat dym
> select CONVERT(DATETIME, '20060405 14:45:43', 102)
> go
> 2006-04-05 14:45:43.000 is returned for every select
>
> Denis the SQL Menace
> http://sqlservercode.blogspot.com/
>|||Hmm... Thanks !
Must be something else... let me investigate.
--alexT|||both of these will work
select CONVERT(DATETIME, '20060405 14:45:43', 102)
select CONVERT(DATETIME, '20060405 14:45:43')
Madhivanan|||Hi again
It wasmy mistake - apparently some embeded control char :(
Thanks for your help !
--alexTsqlsql
No comments:
Post a Comment