开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜