OR
DECLARE @dStartdate DateTime,
@dEndDate DateTime
SET @dStartdate = CAST('10/01/2005 08:00:00' AS DateTime)
SET @dEndDate = GETDATE()
select * from MyTable WHERE MyDate BETWEEN @dStartdate AND @dEndDate
>Ok. How would I use DATEDIFF in the following SQL? I want to test to
>see if a specified date falls in a certain range of dates
>
>
>
>SELECT *;
> FROM MyTable;
> WHERE BETWEEN(MyDate, dStartDate, dEndDate)
>
>
>Thanks
>
>
>
>
>
>>>Ok. While I understand, I don't see what the solution is.
>>>
>>>
>>
>>select *
>> from client
>> where DATEDIFF(s,create_date,'20041117 08:15:37')=0
>>
>>
>>>
>>>>The datetime data type is stored with an accuracy of 1/300 of a second. See
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_da-db_9xut.asp for details.
>>>>
>>>>>I have the Client table open in the Enterprise Manager.
>>>>>
>>>>>The first record has a create_date of "11/17/2004 8:15:37 AM"
>>>>>
>>>>>
>>>>>When I go to the Query Analyzer and run the following, it does not
>>>>>return the record.
>>>>>
>>>>>
>>>>>select *
>>>>> from client
>>>>> where create_date = '2004-11-17 08:15:37'
>>>>>
>>>>>
>>>>>If I do the following, it finds the record. But notice the create_date field value:
>>>>>
>>>>>
>>>>>select *
>>>>> from client
>>>>> where id = 1
>>>>>
>>>>>
>>>>>
>>>>>returns
>>>>>
>>>>>
>>>>>create_date
>>>>>2004-11-17 08:15:36.997
>>>>>
>>>>>
>>>>>Someone explain this please.
_______________________________________________________________
Testing displays the presence, not the absence of bugs.
If a software application has to be designed, it has to be designed correctly!
_______________________________________________________________
Vladimir Zografski
Systems Analyst