On 2017/03/08 9:59 PM, Rob Richardson wrote:
Thank you. The https://www.sqlite.org/lang_datefunc.html page doesn't seem to make it clear what strftime() returns. The specification it gives for strftime() is: strftime(format, timestring, modifier, modifier, ...)
It returns a string, they all return strings. There is no "lack" of a type, there is a lack of an object, but this isn't C. The "str" in the name "strftime()" indicates it is returning a string, in the same way the "f" indicates it is a formatted one at that, and the last part of the name gives a clue as to what it will be returning the formatted string of.
Here's a good list of format specifiers: http://www.faximum.com/manual.d/client.server.d/manpages.23.html
Given the lack of an indication of the return type, it seemed to me to be reasonable to assume that since I'm passing in a string as one of the arguments, I'd get a datetime object out. It did not seem reasonable to me to merely pass in a string of a forced format, the ISO standard format Dr. Hipp mentioned, to get a string in some other format.
Well yeah, it makes no sense if you do it like that... but keeping in mind that function is mostly used in a Data Query where the input is a standard field, the output could be anything your heart desires - which is when this starts making sense.
But I've been burned before by data types, or lack thereof, in SQLite. I usually work in C# and PostgreSQL, where variables and data columns always have definite data types, and, if I remember correctly (it's been a couple of years since I worked with SQLite), SQLite does things differently.
Quite correct, but in no way does it do things willy-nilly. It's "weird" way is very documented, tested to infinity and completely accurate and reproducible. (Sometimes people confuse duck-typing with loose-canon shenanigans). And yes - expecting an integer and finding a string in a field can be surprising, but every language has its quirks, and most people make that mistake only once. :)
Btw - we're all PostgreSQL fans too. Please ask if you have any more questions and good luck! Ryan _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users