Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
What's to like about a datetime
Message
 
À
28/08/2018 08:01:20
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
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Database:
MS SQL Server
Divers
Thread ID:
01661714
Message ID:
01661758
Vues:
79
>>And why would you use like with DateTime? Just for giggles? :-) Besides being invalid it'd also be much less efficient than using = given that like is a pattern matching operation.
>>
>>+++ Rick ---
>
>Invalid???? It is not. It is perfectly valid. And like is not a much less efficient operation than using =. An expression that has wildcard at the end only, utilizes the index.
>
>If your application is dealing a lot with date\datetimes then there is space to use it.

Huh? How would you have a LIKE operation on a DateTime work? Using like automatically will treat the date like a string?

If I have a date like this in the DB:
2015-06-01 11:52:59.057
and you do a query like this:
select * from wws_invoice where invdate like '2015-06-01%'
you get no match.

Unless I miss something here the only way you can get a valid date selection via string is by an exact match:
select * from wws_invoice where invdate = '2015-06-01 11:52:59.057'
The accepted way to do partial date queries is to use DatePart() in TSQL or you can use nasty code to CAST a date to a VARCHAR:

https://stackoverflow.com/questions/1629050/sql-server-datetime-like-select


+++ Rick ---
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform