Hi DMan,
Glad that it worked. (I wasn't checking my mails for the past 2 days, so I couldn't reply you)
Actually I was looking for some realtime data for the following from you, to have suggested a better solution.
1) What is value passed on as querystring.
2) What is value stored in DB
3) How is querystring value compared against Db value.
But I don't find it necessary to set that column default to Convert(char(10), getdate(), 101)
By default Sql server stores all datetime values in db as yyyy-mm-dd hh:mm:ss.000 format and any smalldatetime values as yyyy-mm-dd hh:mm:ss format. So it is enough that you incorporate that format in your where clause to compare that against the DB values.
Just when do a
SELECT smalldatetime_column FROM your_table
You should see that displayed in the format as mentioned above. Though you do a convert() to its default value, still I beleive it stores it in its format except that the time part is made all ZEROs. It is all in the way we pass the values as needed by the db.
Let me explain why it would have worked for you now. Because when you set it to default as just "getdate()" it uses the date with time too(current date & current time - when the value was inserted). But when you use convert() as mentioned, it defaults the value with currentdate and time as 00:00:00
So when you compare the QS values with db values, it is enough that you do like this.
Select * from Table where datecol = qsvalue
(where "2004-09-16 00:00:00" is equivalent to "2004-09-16")
But when it was defaulted to "getdate()", your query would have looked like
Select * from Table where datecol = qsvalue
(where "2004-09-16 01:30:36" is NOT equivalent to "2004-09-16")
That is where you need to strip of the time part on both the side(if exists) and convert comes in to use as I suggested in one of my replies earlier.
This is how it would have solved the problem for you, when you changed it to convert().
Cheers!
_________________________
- Vijay G
Strive for Perfection
|