I am using this Array extension to slice [HKQuantitySample] e.g.
[HKQuantitySample]
let test = samplesWithoutDups.sliced(by: [.year, .month, .day], for: \\.startDate