Is there an equivalent of Sql Server's DateDiff('ms', d1, d2) in Sqlite?
I am trying to fathom if it is possible to calculate the number of elapsed milliseconds between dates in Sqlite. ( DateDiff('milliseconds', d1, d2)
in SQL Server)
There's a great exampl开发者_StackOverflow中文版e on how to do it for seconds here, but not for milliseconds.
You can get there.
Given these 2 dates: 12:00:00:000 & 12:05:01:200
( (
(strftime('%M', EndDate) * 60) -
(strftime('%M', StartDate) * 60)
) +
strftime('%f', EndDate) -
strftime('%f', StartDate)
) * 1000
results in a diff off 301200 (milliseconds)
The key is getting your head around the fact that %f
yields seconds and milliseconds as a fraction of seconds (1.2), and you need to add that onto the total seconds in the minutes.
精彩评论