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.

 All Forums
 Development Tools
 ASP.NET
 The conversion of a char data type to a datetime d

Author  Topic 

txcn87
Starting Member

1 Post

Posted - 2007-09-28 : 07:30:25
In my system I am using language as "en-US (m/d/y)" and at SQL Server side trying to convert the date to UK (d/m/y) format i.e "103". Then getting the error " The conversion of a char data type to a datetime data type resulted in an out-of-range datetime"

Expected is : "Take any language at GUI side that should convert that UK format at server side"

Thanks in advance.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-09-28 : 08:24:05
Homework?



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-09-28 : 08:38:40
You dont need to worry about formatting at server side as long as you use proper DATETIME datatypw to store dates and use datetime parameters in .NET and express dates in global YYYYMMDD HH:MM:SS format when assigning

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-09-28 : 09:00:11
quote:
Originally posted by txcn87

In my system I am using language as "en-US (m/d/y)" and at SQL Server side trying to convert the date to UK (d/m/y) format i.e "103". Then getting the error " The conversion of a char data type to a datetime data type resulted in an out-of-range datetime"

Expected is : "Take any language at GUI side that should convert that UK format at server side"

Thanks in advance.




As already stated, do NOT use CONVERT to try to format dates -- it converts your datetime values to VARCHAR, which your client can then no longer interpret reliably as dates without converting back. Simply return the datetime values and let your client format the results.

Why do people never realize that CONVERTing a datetime to a VARCHAR no longer returns a DATETIME, but a VARCHAR? That's what you are asking for, isn't it?


- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page
   

- Advertisement -