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 |
aoriju
Posting Yak Master
156 Posts |
Posted - 2009-04-08 : 02:11:29
|
Dear All,declare @strDt VARCHAR(20);SET @strDt = '31/1/2009'; --dd/MM/YYYYSELECT CAST(@strDt AS DATETIME) --Error Like out of rangeIn Procedure I want to cast that data into datetime type with MM/dd/YYYY format |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-04-08 : 02:22:49
|
[code]declare @strDt VARCHAR(20);SET @strDt = '31/1/2009'; --dd/MM/YYYYSELECT CONVERT(datetime, @strDt, 103) --Error Like out of range[/code] E 12°55'05.63"N 56°04'39.26" |
|
|
aoriju
Posting Yak Master
156 Posts |
Posted - 2009-04-08 : 02:28:45
|
Any Another Way |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-04-08 : 02:32:36
|
You are not satisfied with a suggestion that works? E 12°55'05.63"N 56°04'39.26" |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-04-08 : 03:04:46
|
quote: Originally posted by aoriju Any Another Way
Express date in YYYYMMDD format MadhivananFailing to plan is Planning to fail |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-04-10 : 06:44:52
|
quote: Originally posted by aoriju Dear All,declare @strDt VARCHAR(20);SET @strDt = '31/1/2009'; --dd/MM/YYYYSELECT CAST(@strDt AS DATETIME) --Error Like out of rangeIn Procedure I want to cast that data into datetime type with MM/dd/YYYY format
why use varchar variable to datetime value? also if you want pass date values always try to use iso format as Madhi suggests. |
|
|
|
|
|