atBeginningOfWeek

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

Name Description

dateTime

The DateTime value to reference.

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

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

Output

{
  "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

Name Description

localDateTime

The LocalDateTime value to reference.

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

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

Output

{
  "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

Name Description

date

The Date value to reference.

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

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

Output

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

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub