Skip to content

aggregateGroupByDuration for Steps & Distance returns data split over 2 days #232

@RonMagu

Description

@RonMagu

Describe the bug

Retrieving step and distance data splits the data over two days (I think due to the zoneOffset).
Adding a walk of 5km and 5000 steps to health connect at 00:51 on 17 Sept, saves this data in Health Connect for the 17 Sept. However, when the below request:

    return await aggregateGroupByDuration({
      recordType: 'Distance',
      timeRangeFilter: {
        operator: 'between',
        startTime: '2025-09-01T00:00:00.000Z',
        endTime: '2025-09-17T01:11:05.084Z',
      },
      timeRangeSlicer: {
        duration: 'DAYS',
        length: 1,
      },
    });

is made, it returns data split across 17 Sept and 16 Sept.

Response snippet:

{
   "zoneOffset":"+01:00",
   "startTime":"2025-09-16T00:00:00Z",
   "endTime":"2025-09-17T00:00:00Z",
   "result":{
      "dataOrigins":[
         
      ],
      "DISTANCE":{
         "inFeet":4425.768538615029,
         "inInches":53109.22246338034,
         "inMiles":0.8382158217467165,
         "inKilometers":1.3489742505698608,
         "inMeters":1348.9742505698607
      }
   }
},
{
   "zoneOffset":"+01:00",
   "startTime":"2025-09-17T00:00:00Z",
   "endTime":"2025-09-17T01:11:05.159Z",
   "result":{
      "dataOrigins":[
         
      ],
      "DISTANCE":{
         "inFeet":11978.430936450586,
         "inInches":143741.17123740705,
         "inMiles":2.268647861502317,
         "inKilometers":3.651025749430139,
         "inMeters":3651.025749430139
      }
   }
}

To Reproduce
Steps to reproduce the behavior:

  1. Add 5km Distance to Health Connect at 00:45 on a specific date
  2. Run the above request and log output
  3. The output will split the distance across 2 days 1348 and 3651 or similar.
  4. Meaning the 5km distance done on 1 day will not be returned for that day.

NOTE: This happens for both steps and distance recordTypes.
This issue was caught when testing at 00:51 in a London/Europe timezone with the zoneOffset at +01:00 (taken from response)

Expected behavior
The response should contain the full distance or steps for the day i.e in this case:

{
   "zoneOffset":"+01:00",
   "startTime":"2025-09-16T00:00:00Z",
   "endTime":"2025-09-17T00:00:00Z",
   "result":{
      "dataOrigins":[
         
      ],
      "DISTANCE":{
         "inFeet":0.0,
         "inInches":0.0,
         "inMiles"0.0,
         "inKilometers":0.0,
         "inMeters":0.0
      }
   }
},
{
   "zoneOffset":"+01:00",
   "startTime":"2025-09-17T00:00:00Z",
   "endTime":"2025-09-17T01:11:05.159Z",
   "result":{
      "dataOrigins":[
         
      ],
      "DISTANCE":{
         "inFeet":...,
         "inInches":...,
         "inMiles":...,
         "inKilometers":5
         "inMeters":5000
      }
   }
}

Environment:

  • Health Connect Version: 3.4.0
  • React Native Version: 0.77.3
  • New architecture enabled: No
  • Using Expo: No
  • Android API Level: e.g API 35

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions