In Feburary 2016 24,
Run SQLite queries from the command prompt with the 'sqlite3' program by typing:$ sqlite3 my_db.dbThis will create a database with the name 'my_db.db' if it doesn't already exist. It also places you in the sqlite3 environment, which you can exit with the commands '.quit', '.q' or '.exit.'
Call the 'strftime (format, timestring, modifier, modifier)' function to return a formatted date from a time string. This is useful for comparing dates, displaying a date in a certain format to a user or to upload a date in a consistent matter. The format of a time string follows the rules from the C 'strftime' function. Some of the valid time string formats include 'YYYY-MM-DD,' 'YYYY-MM-DD HH:MM,' 'YYYY-MM-DD HH:MM:SS,' 'YYYY-MM-DD HH:MM:SS.SSS,' 'DDDDDDDDDD' and 'now.' The 'Y' character stands for year, 'M' for month, 'D' for day, 'H' for hour, 'M' for minute and 'S' for second. The 'DDDDDDDDDD' format represents a unix timestamp. For example, the following query will compute how many seconds have passed since a date in 2002:$ sqlite3 my_db.db SELECT strftime('%s','now') - strftime('%s','2002-05-11 01:56:23');
Call the 'date,' 'time,' 'datetime' or 'julianday' functions to use a pre-formatted version of the 'strftime' function. The 'date' function returns the date with the format 'YYYY-mm-dd,' the 'time' function returns it as 'HH:MM:SS,' the 'datetime' function returns it as 'YYYY-mm-dd HH:MM:SS' and the 'julianday' function returns the Julian day number. For example, the following query will return a date from 2009 as '2009-09-22,' removing the hour, minute and second information:$ sqlite3 my_db.db SELECT date('2009-09-22 02:57:13');
In Feburary 2016 24,
No comments:
Post a Comment