Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Select by Date from DateTime in SQL Server
Message
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:
01653214
Vues:
96
This message has been marked as the solution to the initial question of the thread.
>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?

Hi Dmitry,

The question is "How to remove time from datetime"?
/* MS SQL 2008R2 + */
select * from MyTable where CAST(DateTimeCol AS DATE) <= '20170810'  

/* MS SQL*/
select * from MyTable where CAST(CAST(DateTimeCol AS INT) AS DATETIME) <= '20170810'  
MartinaJ
"Navision is evil that needs to be erazed... to the ground"

Jabber: gorila@dione.zcu.cz
Jabber? Jabbim
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform