Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
DATETIME Question
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
01083372
Message ID:
01083749
Vues:
8
SELECT * FROM MyTable
       WHERE MyDate BETWEEN CAST('02/01/2005 08:00:00' as DateTime)
                        AND CAST('02/15/2005 09:00:00' as DateTime)
>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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform