Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Select by Date from DateTime in SQL Server
Message
From
11/08/2017 09:14:40
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
 
To
11/08/2017 06:20:51
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01653212
Message ID:
01653244
Views:
41
>>Similar to what I was doing a dozen years ago:
>>
>>
select * from MyTable where DateTimeCol <= '20170810 23:59:59'
>
>In a fast moving environment, that would miss the records entered after 23:59:59 (and it happened to me in real life, was a hard to catch bug).

What was the content in those records, assuming it was a datetime? For datetime2 it would obviously be
select * from MyTable where DateTimeCol <= '20170810 23:59:59.9999'
If the record was entered after 23:59:59, I'd assume the actual value would be rounded to whole seconds. Those in the first half would be rounded into the ":59" part, the rest would be in the next day. Unless it was the VFP5 with hidden milliseconds?

>Once upon a time Naomi made me aware of date range queries using BETWEEN - which uses <e; (thanks Naomi). Since then I realised the only reliable way is to use < operator for the ending value. Converting to date would work but that is an unnecessary overhead. With this approach, it works very well whether the type is a date, date time, datetime2 ...

Yup, handles those pesky fractions as well.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Reply
Map
View

Click here to load this message in the networking platform