"Turn" method for SQLite DateDiff date-time subtraction

Source: Internet
Author: User
Tags sqlite

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.