Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Select by Date from DateTime in SQL Server
Message
 
 
À
11/08/2017 05:00:11
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01653212
Message ID:
01653243
Vues:
68
>>Hi,
>>
>>I am working with the SQL Server database. The field/column is DateTime. And I want to get records by the following criteria:
>>
>>
>>select * from MyTable where DateTimeCol <= '20170810'  
>>
>>
>>Since the DateTimeCol has both the date and time, the above will select 0 records.
>>
>>How should I change the WHERE to make sure that only the Date of DateTime is considered and therefore the records where the Date is '20170810' are returned?
>
>Simply:
>
>
>select * from MyTable where DateTimeCol < '20170811'  
>
Thank you, Cetin. It is just that my existing code already uses the Less Than or Equal (not Less Than) and the approach suggested by Martina (cast DateTimeCol as date) works perfectly.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform