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

# 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"
}
```
