atBeginningOfYear

atBeginningOfYear(dateTime: DateTime): DateTime

Takes a DateTime value as input and returns a DateTime value for the first day of the year specified in the input. It also sets the Time value to 00:00:00.

The month, day, and time in the input changes to 01-01T00:00:00.

Introduced in DataWeave version 2.4.0.

Parameters

Name Description

dateTime

The DateTime value to reference.

Example

This example transforms the DateTime input (|2020-10-06T18:23:20.351-03:00|) to the date of the first day of the Year value (2020) in the input.

Source

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

Output

{
  "atBeginningOfYearDateTime": "2020-01-01T00:00:00.000-03:00"
}

atBeginningOfYear(localDateTime: LocalDateTime): LocalDateTime

Takes a LocalDateTime value as input and returns a LocalDateTime value for the first day of the year specified in the input. It also sets the Time value to 00:00:00.

The month, day, and time in the input changes to 01-01T00:00:00.

Introduced in DataWeave version 2.4.0.

Parameters

Name Description

localDateTime

The LocalDateTime value to reference.

Example

This example transforms the LocalDateTime input (|2020-10-06T18:23:20.351|) to the date of the first day of the Year value (2020) in the input.

Source

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

Output

{
  "atBeginningOfYearLocalDateTime": "2020-01-01T00:00:00"
}

atBeginningOfYear(date: Date): Date

Takes a Date value as input and returns a Date value for the first day of the year specified in the input.

The month and day in the input changes to 01-01.

Introduced in DataWeave version 2.4.0.

Parameters

Name Description

date

The Date value to reference.

Example

This example transforms Date input (|2020-10-06|) to the date of the first day of the Year value (2020) in the input.

Source

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

Output

{
  "atBeginningOfYearDate": "2020-01-01"
}

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub