Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Date comparisons
Message
From
17/06/2004 13:18:14
 
 
To
17/06/2004 13:10:04
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00914601
Message ID:
00914686
Views:
10
Bonnie that is a great point. I just wish I could simply use Like '2004-05-04%' :(

You rock as usuall,

>Joe,
>
>>between @logdate and @logdate2", where @logdate2 is @logdate + 1
>
>One gotcha with this is that the BETWEEN clause is all inclusive, so that, in your example, this would include midnite of the following day, which is typically not what you want. That's why I said in my reply to use >= and < rather than BETWEEN.
>
>~~Bonnie
>
>
>>Short and sweet. SQL datetime fields always return a full date time. Which is a double sided sword.
>>
>>While searching for all records on a particular day a where clause is used like "where logdate = @logdate", when they are passing @logdate as '01/01/2004'. '01/01/2004' really means '01/01/2004 00:00:00.000' and will not return data for the complete day.
>>
>>The problem can be solved by using the between clause. The where clause for such a query should be "where logdate between @logdate and @logdate2", where @logdate2 is @logdate + 1. The between clause can make use of an index if it exists, where using a convert function like "where convert(varchar,logdate,101) = @logdate" would not and it would slow down the query.
>>
>>HTH,
~Joe Johnston USA

"If ye love wealth better than liberty, the tranquility of servitude better than the animated contest of freedom, go home from us in peace. We ask not your counsel or arms. Crouch down and lick the hands which feed you. May your chains set lightly upon you, and may posterity forget that ye were our countrymen."
~Samuel Adams

Previous
Next
Reply
Map
View

Click here to load this message in the networking platform