Add Date Function Calls

Last update: Edit

1 Introduction

Add date function calls adds a time unit to a specific date and returns a modified value.

The first input can be either a new Date and time (used in the examples below), a variable of type Date and time, or an attribute of a domain model entity of type Date and time.

2 addMilliseconds

The addMilliseconds function adds a specified number of milliseconds to a date.

2.1 Input Parameters

Use the following input parameters:

  • Initial date Type: Date and time
  • The number of milliseconds to be added Type: Integer

2.2 Output

The expression will result in a Date and time value that is the sum of the initial date and N milliseconds.

2.3 Example

If you type in the following input:

addMilliseconds(dateTime(2007, 1, 1, 1, 1, 1), 1400)

The output is:

"Mon Jan 01 01:01:02:400 CET 2007"

3 addSeconds

The addSeconds function adds a specified number of seconds to a date.

3.1 Input Parameters

Use the following input parameters:

  • Initial date Type: Date and time
  • The number of seconds to be added Type: Integer

3.2 Output

The expression will result in a Date and time value that is the sum of the initial date and N seconds.

3.3 Example

If you type in the following input:

addSeconds(dateTime(2007, 1, 1, 1, 1, 1), 2)

The output is:

"Mon Jan 01 01:01:03 CET 2007"

4 addMinutes

The addMinutes function adds a number of minutes to a date.

4.1 Input Parameters

Use the following input parameters:

  • Initial date Type: Date and time
  • The amount of minutes to be added Type: Integer

4.2 Output

The expression will result in a Date and time value that is the sum of the initial date and N minutes.

4.3 Example

If you type in the following input:

addMinutes(dateTime(2007, 1, 1, 1, 1, 1), 3)

The output is:

"Mon Jan 01 01:04:01 CET 2007"

5 addHours

The addHours function adds a number of hours to a date.

5.1 Input Parameters

Use the following input parameters:

  • Initial date Type: Date and time
  • The amount of hours to be added Type: Integer

5.2 Output

The expression will result in a Date and time value that is the sum of the initial date and N hours.

5.3 Example

If you type in the following input:

addHours(dateTime(2007, 1, 1, 1, 1, 1), 25)

The output is:

"Mon Jan 02 02:01:01 CET 2007"

6 addDays[UTC]

The addDaysUTC function adds a number of days to a date. addDays uses the server’s calendar and addDaysUTC uses the UTC calendar.

6.1 Input Parameters

Use the following input parameters:

  • Initial date Type: Date and time
  • The amount of days to be added Type: Integer

6.2 Output

The expression will result in a Date and time value that is the sum of the initial date and N days.

6.3 Example

If you type in the following input:

addDays(dateTime(2007, 1, 1, 1, 1, 1), 3)

The output is:

"Mon Jan 04 01:01:01 CET 2007"

7 addWeeks[UTC]

The addWeeksUTC function adds a number of weeks to a date using the UTC calendar as opposed to addWeeks which uses the server’s one.

7.1 Input Parameters

Use the following input parameters:

  • Initial date Type: Date and time
  • The amount of weeks to be added Type: Integer

7.2 Output

The expression will result in a Date and time value that is the sum of the initial date and N weeks.

7.3 Example

If you type in the following input:

addWeeks(dateTime(2007, 1, 1, 1, 1, 1), 2)

The output is:

"Mon Jan 15 01:01:01 CET 2007"

8 addMonths[UTC]

The addMonthsUTC function adds a number of months to a date using the UTC calendar as opposed to addMonths which uses the server’s one.

8.1 Input Parameters

Use the following input parameters:

  • Initial date Type: Date and time
  • The amount of months to be added Type: Integer

8.2 Output

The expression will result in a Date and time value that is the sum of the initial date and N months.

8.3 Example

If you type in the following input:

addMonths(dateTime(2007, 1, 1, 1, 1, 1), 13)

The output is:

"Mon Feb 01 01:01:01 CET 2008"

9 addYears[UTC]

The addYearsUTC function adds a number of years to a date using the UTC calendar as opposed to addYears which uses the server’s one.

9.1 Input Parameters

Use the following input parameters:

  • Initial date Type: Date and time
  • The amount of years to be added Type: Integer

9.2 Output

The expression will result in a Date and time value that is the sum of the initial date and N years.

9.3 Example

If you type in the following input:

addYears(dateTime(2007, 1, 1, 1, 1, 1), 11)

The output is:

"Mon Jan 01 01:01:01 CET 2018"

10 Passing Values of the Long Type

It is possible to pass values of the Long type to different Add date function calls:

If you type in the following input:

addSeconds(dateTime(1970, 1, 1, 0, 0, 0), (long)(2147483647 + 100))

The output is:

"Tue Jan 19 04:15:47 CET 2038"