---
title: "setSelection"
description: "Sets the [DateRangePickerState] start and end dates selection.

The provided [LocalDate]s are converted to the start of the day (midnight) in UTC and applied to
the [DateRangePickerState].

The function expects the dates to be within the state's year-range, and for the start date to
appear before, or be equal, the end date. Also, if an end date is provided (e.g. not `null`), a
start date is also expected to be provided. In any other case, an [IllegalArgumentException] is
thrown."
type: "function"
---

<div class='type'>Function</div>


<a id='references'></a>
<div class='sourceset sourceset-jvmAndAndroid'>JvmAndAndroid</div>


```kotlin
@RequiresApi(26)
fun DateRangePickerState.setSelection(startDate: LocalDate?, endDate: LocalDate?)
```


Sets the `DateRangePickerState` start and end dates selection.

The provided `LocalDate`s are converted to the start of the day (midnight) in UTC and applied to
the `DateRangePickerState`.

The function expects the dates to be within the state's year-range, and for the start date to
appear before, or be equal, the end date. Also, if an end date is provided (e.g. not `null`), a
start date is also expected to be provided. In any other case, an `IllegalArgumentException` is
thrown.

#### Parameters

| | |
| --- | --- |
| startDate | a `LocalDate` that represents the start date selection. Provide a `null` to indicate no selection. |
| endDate | a `LocalDate` that represents the end date selection. Provide a `null` to indicate no selection. |




