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 |
|
Deep123
Starting Member
8 Posts |
Posted - 2009-06-17 : 07:54:19
|
| this is not working for me pls helpselect * FROM documents where uploadeddate between '23/5/2009' and '11/7/2009'and uploadedate col is no datetime its an varchar |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-06-17 : 08:00:32
|
| declare @fromdate datetime,@todate datetimeselect @fromdate ='5/23/2009' ,@todate = '7/11/2009'select * FROM documents where dateadd(d,datediff(d,0,uploadeddate),0) between @fromdate and @todateuse dateformat as mm/dd/yyyy or universal format |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-06-17 : 08:00:39
|
What datetype is UploadedDate? E 12°55'05.63"N 56°04'39.26" |
 |
|
|
Nageswar9
Aged Yak Warrior
600 Posts |
Posted - 2009-06-17 : 08:03:45
|
| it is varchar, use bklr's solution it is useful for u |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-06-17 : 08:04:41
|
And for the 100th time bklr, DO NOT apply functions over a column that might be indexed.You render the index useless and the query may take ages to run, because the query engine has to scan the table instead of searching. E 12°55'05.63"N 56°04'39.26" |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-06-17 : 08:06:53
|
Deep123, why are you using varchar to store dates?What is the reason behind this decision? E 12°55'05.63"N 56°04'39.26" |
 |
|
|
Deep123
Starting Member
8 Posts |
Posted - 2009-06-17 : 08:10:49
|
quote: Originally posted by Peso Deep123, why are you using varchar to store dates?What is the reason behind this decision? E 12°55'05.63"N 56°04'39.26"
it has been set before i cant chnge it nowone reason is tht if empty date inserted then it takes tht day date |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-06-17 : 08:14:35
|
That can be fixed by adding a default value.But if "it" takes todays' date, why not add a computed column?I guess you search a lot from this table with help of date ranges? E 12°55'05.63"N 56°04'39.26" |
 |
|
|
|
|
|
|
|