---
schema_version: "1"
id: 17234599ec5aa53e91cc9299660c00050e534e9339276e95983dc066d6c74e5a
title: atBeginningOfWeek
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.12/dw-dates-functions-atbeginningofweek.md
canonical_url: https://docs.mulesoft.com/dataweave/2.12/dw-dates-functions-atbeginningofweek
source_site: docs.mulesoft.com
content_type: documentation
content_hash: b8ac08f3ff8831a66a0bdb3fb9225f1794aec303f026c6427150111227bb18e8
description: MuleSoft Documentation Site
release: "2.12"
latest: false
---
---
product: DataWeave
version: 2.12
---

# atBeginningOfWeek

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

## atBeginningOfWeek(dateTime: DateTime): DateTime

Returns a new `DateTime` value that changes the `Day` and `Time` values from the input to the
beginning of the first day of the specified _week_.

The function treats Sunday as the first day of the week.

_Introduced in DataWeave version 2.4.0._

### Parameters

<table><colgroup><col> <col></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><p><code>dateTime</code></p></td><td><div><div><p>The <code>DateTime</code> value to reference.</p></div></div></td></tr></tbody></table>

### Example

This example changes the `Day` and `Time` values (`06T18:23:20.351`) within the `DateTime` input to
the beginning of the first day of the specified _week_ (`04T00:00:00`).

#### Source

```DataWeave
%dw 2.0
import * from dw::core::Dates
output application/json
---
{
  atBeginningOfWeekDateTime: atBeginningOfWeek(|2020-10-06T18:23:20.351-03:00|)
}
```

#### Output

```Json
{
  "atBeginningOfWeekDateTime": "2020-10-04T00:00:00-03:00"
}
```

## atBeginningOfWeek(localDateTime: LocalDateTime): LocalDateTime

Returns a new `LocalDateTime` value that changes the `Day` and `Time` values from the input to the
beginning of the first day of the specified _week_.

The function treats Sunday as the first day of the week.

_Introduced in DataWeave version 2.4.0._

### Parameters

<table><colgroup><col> <col></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><p><code>localDateTime</code></p></td><td><div><div><p>The <code>LocalDateTime</code> value to reference.</p></div></div></td></tr></tbody></table>

### Example

This example changes the `Day` and `Time` values (`06T18:23:20.351`) within the `LocalDateTime`
input to the beginning of the first day of the specified _week_ (`04T00:00:00`).

#### Source

```DataWeave
%dw 2.0
import * from dw::core::Dates
output application/json
---
{
  atBeginningOfWeekLocalDateTime: atBeginningOfWeek(|2020-10-06T18:23:20.351|)
}
```

#### Output

```Json
{
  "atBeginningOfWeekLocalDateTime": "2020-10-04T00:00:00"
}
```

## atBeginningOfWeek(date: Date): Date

Returns a new `Date` value that changes the `Date` input input to the first day of the specified
_week_.

The function treats Sunday as the first day of the week.

_Introduced in DataWeave version 2.4.0._

### Parameters

<table><colgroup><col> <col></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><p><code>date</code></p></td><td><div><div><p>The <code>Date</code> value to reference.</p></div></div></td></tr></tbody></table>

### Example

This example changes the `Day` value (`06`) within the `Date` input to the first day of the week
that contains `2020-10-06` (a Tuesday), which is `2020-10-04` (a Sunday). The `Day` value changes
from `06` to `04`.

#### Source

```DataWeave
%dw 2.0
import * from dw::core::Dates
output application/json
---
{
  atBeginningOfWeekDate: atBeginningOfWeek(|2020-10-06|)
}
```

#### Output

```Json
{
  "atBeginningOfWeekDate": "2020-10-04"
}
```
