Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
What's to like about a datetime
Message
From
24/08/2018 06:57:17
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
 
To
23/08/2018 18:34:19
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:
01661726
Views:
61
>>Out of curiosity, I tried
>>
>>
select * from mylogins 
>>where logintime like '2013-08-06 17:51:18'
>>
>>and a few other combinations, with % in some places. No error, no result.
>>
>>Too bad - SQL server throws errors for all kinds of funny reasons, yet this goes by silently. And it could actually be useful for partial date search - when you know only the decade and month, or some other parts of the date. It's silly to use plain strings as date literals in the first place, and then even sillier to never fix the statement parser to not allow this. Yes, the argument to compare with is a string literal, but that doesn't mean that all operators that apply to strings make sense.
>
>
>Dragan,
>SQL server (and VFP too) wouldn't raise an error if there is no matching records to a given criteria. Thus SQL server, not giving any results, is more of a question here. The reason is that, really you wouldn't find any results for that given string and there is no error.
>
>If you read the documentation for LIKE it says:
>
>"If any one of the arguments is not of character string data type, the SQL Server Database Engine converts it to character string data type, if it is possible."
>
>A DateTime value is convertible to string, thus it is converted to check for a match (almost any types are convertible to string).
>
>Now try:
>
>
select * from mylogins 
>    where logintime like 'Aug 6 2013 5:51PM'
>
>select * from mylogins 
>    where logintime like 'Aug 6 2013%'
>
>
>Datetime default format is 100 (mon dd yyyy hh:miAM (or PM)).
>
>As per the blog pointed out by Greg, unfortunately anyone can write blogs with or without correct information in it.

Wow, didn't know this... even "where pk like '800%' " actually works and returns the expected result. Who'd a thunk...

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