To SQLite both hate and love, in small projects, with SQLite developed very convenient, efficient enough. The drawback is that SQLite has streamlined some functions and related functions. such as stored procedures, DATEDIFF, does not support concurrent write and remote access (perhaps some experts say this is not a problem, with sharing or IIS can be resolved, but this is really solved?). ), leading to a lot of detours in the development process.
The most commonly used date and time comparison function, DateDiff, was streamlined in sqlite and could not find a detailed implementation method on the Web. Today it took some time to realize DateDiff function.
After a period of time to find that SQLite has a julianday function conversion can be directly subtracted, the result is the number of days (day) value, if less than one day will be expressed in decimal. Then thought should be able to be used to convert the time, that is, you can make time comparisons, such as to calculate the accurate to hour level comparison, can be so SQLite "select (Julianday (' 2013-10-09 17:40 ')-Julianday ( Strftime ('%y-%m-%d%h:%m ', datetime (' Now ', ' localtime '))) *24. The precise to minute comparison can be *24*60.
Julianday is easy to take for granted that it is simple to compare day, if there is datediff that much good ...
"Turn" method for SQLite DateDiff date-time subtraction