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 |
|
brendalisalowe
Constraint Violating Yak Guru
269 Posts |
Posted - 2005-03-24 : 13:57:01
|
| Can anyone tell me why this won't work? SELECT CaseNumberFROM tblCapRec WHERE CONVERT(CHAR(10),mailedfirst,101) = CONVERT(CHAR(10),'3/24/2005',101)I know the mailedfirst date does equal 3/24/2005. What am I doing wrong with the dates? Thanks!BrendaIf it weren't for you guys, where would I be? |
|
|
cshah1
Constraint Violating Yak Guru
347 Posts |
Posted - 2005-03-24 : 14:04:21
|
| SELECT CaseNumberFROM tblCapRec WHERE CONVERT(CHAR(10),mailedfirst,101) = CONVERT(CHAR(10),'03/24/2005',101) |
 |
|
|
brendalisalowe
Constraint Violating Yak Guru
269 Posts |
Posted - 2005-03-24 : 14:05:35
|
| Well, that was easy. THANKS!BrendaIf it weren't for you guys, where would I be? |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2005-03-24 : 19:41:48
|
When you are selecting by date from a table, you should leave the table datetime column as it is, instead of converting it to CHAR to compare. If you convert it to CHAR, it cannot use any index on the column, and it is also more overhead to convert it.select CaseNumberfrom tblCapRec where -- Select for entire day of 2005/03/24 mailedfirst >= convert(datetime,'2005/03/24') and mailedfirst < convert(datetime,'2005/03/25') CODO ERGO SUM |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
|
|
|
|
|
|
|