Healthkit queries

From James Van Dyne
Jump to navigation Jump to search

By converting my HealthKit data to sqlite using healthkit-to-sqlite I have a SQL queriable dataset of my heatlh. Here are some fun queries to run

Handwashing[edit]

Handwashing Session Duration[edit]

Average handwashing time by date

select
  substr(creationDate, 1, 10) as label,
  date(substr(creationDate, 1, 10)) as recordDate,
  avg(
    round(
      (
        julianday(replace(endDate, " +0900", "")) - julianday(replace(startDate, " +0900", ""))
      ) * 86400.0
    )
  ) as average
from
  rHandwashingEvent
group by
  label;