How can a difference between timestamps be expressed as fractional days?
julianday maps timestamps to floating-point day numbers. Their difference gives elapsed days including fractional days.
SQLite example and interpretation
Six in the morning to six in the evening spans half a day. The calculation uses floating arithmetic. Use integer timestamps for exact whole-second reconciliation.
SELECT julianday('2024-01-01 18:00')-julianday('2024-01-01 06:00');Result [[0.5]]
中文
如何把两个日期时间之间的差值直接表示为天?
julianday 返回以日为单位的浮点数,两个值之差可表示含小数部分的天数。
SQLite 示例与适用条件
上午六点到下午六点是半天。该方法采用浮点运算,若要求整数秒精确对账,可改用整数时间戳。
SELECT julianday('2024-01-01 18:00')-julianday('2024-01-01 06:00');结果 [[0.5]]