SQLite Functions

I was trying to figure out how to display an integer as a date and time in SQLite3. And it’s documented, and documented very, very well. Problem is, so is the code base, so when I looked for time conversion functions for SQLite, even browsing the Wiki, I kept getting the developer pages, not the SQL core functions. But, I found them. And now I’m documenting where so I can get to them at a later date.

Seems silly, but I’ve been using SQLite and was having the darnedest time try to convert an integer into a time. Problem was, I knew the functions for Sqlite3 had to be out there, but all I kept getting from search engines and exploring the developer Wiki were the C/C++ API functions, not the ones needed for SQL. I guess the way the pages are indexed, the source pages score higher than the user manual pages.

Anyhow, located the SQL functions and wanted to document their location for myself so I could locate them again later.

Seems they are called Core Functions.

They hide under the language expression page, which is under the SQL language page.

I was thrilled to find that the SQLite C Interface allowed the creation of your own functions. Brilliant!

Turns out, that the date and time functions were hiding in a different part on the Wiki.

The magic I wanted, given a time stored in an integer, was:
SELECT datetime(timevalue, 'unixepoch', 'localtime');

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.