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 |
learning_grsql
Posting Yak Master
230 Posts |
Posted - 2014-06-12 : 05:11:16
|
Hi,The following codes give me the error "arithmetic overflow error converting expression to data type datetime"Unfortunately, the datatype of date of this database is still varchar(50)select date from tbltransactionwhere datepart(wk,convert(datetime,date,103)) = 15 |
|
ahmeds08
Aged Yak Warrior
737 Posts |
Posted - 2014-06-12 : 05:27:19
|
can you try thisselect date from tbltransactionwhere datepart(wk,convert(varchar(10),date,103)) = 15Javeed Ahmed |
 |
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2014-06-12 : 11:33:32
|
You have bad dates stored in your database or they are not in the 103 (dd/mm/yyyy) format. If you can, you should update your database to use the proper data type so you don't have these sorts of issues. |
 |
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2014-06-12 : 11:35:00
|
quote: Originally posted by ahmeds08 can you try thisselect date from tbltransactionwhere datepart(wk,convert(varchar(10),date,103)) = 15Javeed Ahmed
I don't think that makes any sense. Why would you convert a varchar to a varchar specifying a format that doesn't apply to a varchar and then let sql try to implicitly cast it to a datetime? |
 |
|
|
|
|