<!--
{
  "availability" : [
    "iOS: 12.0.0 -",
    "iPadOS: 12.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 5.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "HealthKit",
  "identifier" : "/documentation/HealthKit/HKQuantitySeriesSampleBuilder/insert(_:at:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "HealthKit"
    ],
    "preciseIdentifier" : "c:objc(cs)HKQuantitySeriesSampleBuilder(im)insertQuantity:date:error:"
  },
  "title" : "insert(_:at:)"
}
-->

# insert(_:at:)

Adds a new quantity to the series at the provided date and time.

```
func insert(_ quantity: HKQuantity, at date: Date) throws
```

## Parameters

`quantity`

The quantity to insert.

`date`

The start date associated with the quantity. If this is the same start date as a previously provided quantity, this quantity replaces the previous one. This method fails with an [`HKError.Code.errorInvalidArgument`](/documentation/HealthKit/HKError/Code/errorInvalidArgument) error if the `date` parameter is earlier than the series builder’s [`startDate`](/documentation/HealthKit/HKQuantitySeriesSampleBuilder/startDate) property.

## Discussion

This method calls [`insert(_:for:)`](/documentation/HealthKit/HKQuantitySeriesSampleBuilder/insert(_:for:)), passing a date interval with the provided start date, and a duration of `0`.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)