---
title: "insert(_:at:)"
framework: healthkit
role: symbol
role_heading: Instance Method
path: "healthkit/hkquantityseriessamplebuilder/insert(_:at:)"
---

# insert(_:at:)

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

## Declaration

```swift
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 doc://com.apple.healthkit/documentation/HealthKit/HKError/Code/errorInvalidArgument error if the date parameter is earlier than the series builder’s doc://com.apple.healthkit/documentation/HealthKit/HKQuantitySeriesSampleBuilder/startDate property.

## Discussion

Discussion This method calls insert(_:for:), passing a date interval with the provided start date, and a duration of 0.

## See Also

### Adding Values

- [insert(_:for:)](healthkit/hkquantityseriessamplebuilder/insert(_:for:).md)
