On 11 Jul 2018, at 3:25pm, Stephen Chrzanowski <pontia...@gmail.com> wrote:

> interest is modifying the Stop part so that at a minimum, there is a 10
> minute delta between the start and end time.  So if I start a timer at
> 11:00, then stop at 11:01, I want the database to update the end time to
> 11:10.

To round a timestamp to ten minutes ...

Get the timestamp as a string using datetime(now)
    --> "YYYY-MM-DD HH:MM:SS"

Get the first 15 characters of it using substr(X,1,15)
    --> "YYYY-MM-DD HH:M"

Append "0:00" using the || operator
    --> "YYYY-MM-DD HH:M0:00"

All together now:

    substr(datetime(now),1,15) || "0:00"

Then convert the string back into whatever form you want to store your dates in.

If you do this to two times close together, you may end up with two results 
which are the same.  In other words, your timestamp field cannot have a UNIQUE 
requirement.

Simon.
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to