Dmitry,
SQL server is compatible with ANSISQL92. IOW to SQL server "=" and "==" are same (ANSI on).
Cetin
>Today is Wednesday and it is before 10 am; therefore I am allowed to ask a stupid question <g>. I know that since Sergey and Cetin (two guys with "above average" <g> IQ) replied with basically the same method, I don't doubt that they have the right suggestion.
>
>But why not use "==" when comparing DateField and @DateOnly?
>
>>Should be faster if you have an index on the datetime field. It also doesn't look more complex to me, I use this idea everytime in VFP, though.
>>
>>>Thanks for your reply Sergey. As always I value your response a lot. I find your syntaxt more difficult to read than my method, but the big question is: Is your way better, i.e., faster than my method?
>>>
>>>Thanks,
>>>Einar
>>>
>>>>
>>>>DECLARE @DateOnly datetime
>>>>SET @DateOnly = DATEADD(dd, DATEDIFF(dd, dt, @DateField), dt)
>>>>...
>>>>WHERE DateField >= @DateOnly AND DateField < @DateOnly + 1
>>>>
>>>>
>>>>>Consider the following select statement:
>>>>>
>>>>>SELECT [Id]
>>>>>FROM [MyTable]
>>>>>WHERE YEAR(DateField) = YEAR(@DateField) AND
>>>>> MONTH(DateField) = MONTH(@DateField) AND
>>>>> DAY(DateField) = DAY(@DateField)
>>>>>
>>>>>
>>>>>I want to select the records that have the same date as the parameter, but I do not care about the time part of the field or parameter.
>>>>>Is there another (better) way of doing this?
>>>>>
>>>>>