1

I want to calculate total difference between two date fields in SQLite (they are declared as REAL). I.E. datefield1 and datefield2 and group by day.

Datefield1 is login date, datefield2 is logout date. Each day, user can login/logout several times. I want to sum up login time of a user (datefield2-datefield1) for each day.

Sanyin
  • 41
  • 2
  • 8

1 Answers1

1

SOLVED:

Query

select id, datetime(logindate), datetime(logoutdate), 
sum((julianday(logoutdate) - julianday(logindate)))
from MyTable GROUP BY strftime('%d', logindate);
Ullas
  • 11,450
  • 4
  • 33
  • 50
Sanyin
  • 41
  • 2
  • 8