Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
What's to like about a datetime
Message
From
02/09/2018 15:56:13
John Ryan
Captain-Cooker Appreciation Society
Taumata Whakatangi ..., New Zealand
 
 
To
29/08/2018 19:48:23
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Database:
MS SQL Server
Miscellaneous
Thread ID:
01661714
Message ID:
01661813
Views:
76
Likes (1)
>>I don't think your searches was for exact matches. Otherwise you would know that by now. MS SQL server datetime is only have a sensitivity of 3 milliseconds.

More typically BETWEEN or >=?MyDateTime used in parameterized queries without issue since last century. These are converted to SQL @parameterized queries via ODBC for execution plan caching and SQL-injection-proof development. The identical parameterized query also works equally well for Oracle vs SQL Server despite different datetime layouts if you concatenate your parameters into SQL

>>I don't understand what your comment "which casting to string often did not" means at all.

Per Rick's examples, explicit or implicit casting won't always benefit from an index on a datetime field. I don't believe SQL Server stores datetime as a string, so comparing datetime to a string value using LIKE or anything else, risks a table scan. JMHO, I'm a great believer in KISS and parameterized queries are as simple as it gets IMHO.
"... They ne'er cared for us
yet: suffer us to famish, and their store-houses
crammed with grain; make edicts for usury, to
support usurers; repeal daily any wholesome act
established against the rich, and provide more
piercing statutes daily, to chain up and restrain
the poor. If the wars eat us not up, they will; and
there's all the love they bear us.
"
-- Shakespeare: Coriolanus, Act 1, scene 1
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform