PALATINELABSDocsENES

Pages

↑↓ to moveEnter to openEsc to close

Date and time package guide

Use Date and time actions to parse, calculate, format, and compare dates with stored UTC offsets.

Version 2.17.1. Installed versions can differ. Examples are illustrative and not tested. See Packages.

Jump to actions

Prerequisites

Nothing to install, and no session.

Custom patterns (Assign and To string) use these letters:

WriteMeans
yyyy MM ddyear, month, day (u also means year)
HH / hhhour 0-23 / 1-12
mm ssminutes, seconds
SSSparts of a second, up to 7 digits (n too)
aAM or PM
EEE / EEEEMon / Monday (1 to 3 E give the short name)
X (or x⁠, Z)offset, like +00:00
'T'the letter T as is

Other characters are used as they are. Not all Java pattern letters work.

The named formats below show To string for 2011-12-03T10:15:30+00:00. Time-only formats work only in To string. In Assign, a date-only value without an offset gives midnight UTC.

Named formatTo string outputAssign input forms
BASIC_ISO_DATE20111203+00:00yyyyMMdd with or without +HH:mm offset.
ISO_LOCAL_DATE2011-12-03yyyy-MM-dd⁠.
ISO_OFFSET_DATE2011-12-03+00:00yyyy-MM-dd plus +HH:mm offset.
ISO_DATE2011-12-03+00:00Same date with or without +HH:mm offset.
ISO_LOCAL_TIME10:15:30Not an Assign choice.
ISO_OFFSET_TIME10:15:30+00:00Not an Assign choice.
ISO_TIME10:15:30+00:00Not an Assign choice.
ISO_LOCAL_DATE_TIME2011-12-03T10:15:30yyyy-MM-dd'T'HH:mm:ss⁠, with optional .fff⁠, or minute precision yyyy-MM-dd'T'HH:mm⁠. No offset.
ISO_OFFSET_DATE_TIME2011-12-03T10:15:30+00:00Seconds plus +HH:mm⁠, optional .fff before offset; also seconds without offset.
ISO_ZONED_DATE_TIME2011-12-03T10:15:30+00:00Same as ISO_OFFSET_DATE_TIME⁠; no bracketed zone ID.
ISO_DATE_TIME2011-12-03T10:15:30+00:00Same as ISO_OFFSET_DATE_TIME⁠.
ISO_ORDINAL_DATE2011-337Year and day-of-year, for example 2011-337⁠; UTC midnight.
ISO_WEEK_DATE2011-W48-6ISO week year, week, weekday Monday=1 through Sunday=7; UTC midnight.
ISO_INSTANT2011-12-03T10:15:30ZSeconds with literal Z⁠, with optional .fff before Z⁠; UTC.
RFC_1123_DATE_TIMESat, 03 Dec 2011 10:15:30 GMTRFC 1123 text in English with GMT⁠; UTC.

ISO_INSTANT and RFC_1123_DATE_TIME change the time to UTC. The others keep the stored time; the local forms leave out the offset. Named outputs show no parts of a second. Named time zones are not supported.

Shared fields

Datetime input: a Datetime variable such as $when$, or a date written like 2024-03-15T10:30:00+00:00. Without an offset, UTC is used. Write the offset to avoid surprises. Convert a String variable with Assign first.

Add/Subtract: a negative val goes the other way. MILLIS is milliseconds and WEEKS is 7 days. MILLIS through WEEKS can take parts, like 1.5. MONTHS and YEARS use whole numbers only (1.5 becomes 1) and follow the calendar. If the day does not exist, you get the last day of the month: Jan 31 + 1 month = Feb 29 in 2024. The offset stays the same.

First/Last day of month/year: the time and offset stay; the time is not set to midnight. A date already on that day does not change. Leap years count.

Next/Previous weekday: daysOfWeek takes MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY or SUNDAY. includeInputIfMatch=true: if the date is already that weekday, keep it. false: always move, so a Friday goes to the next or previous Friday. The time and offset stay.

Next/Previous working date: working days are Monday to Friday, minus the dates in holidayDates. The input date itself never counts. Give a List of date texts or Datetime items, such as 2024-03-18T00:00:00+00:00. Only the calendar date is compared. Empty or bad entries are skipped. There is no built-in holiday list. The time and offset stay.

These rows are the same in many actions. Each action's Inputs part says which it uses.

IdentifierEditor fieldType; required; defaultUse
sourceSource date and time variableDatetimedefault 0001-01-01T00:00:00+00:00optionalThe date to use. See Datetime input.
otherDate and time variable to be compared toDatetimedefault 0001-01-01T00:00:00+00:00optionalThe date to compare with. See Datetime input.
inputDateInput datetimeDatetimedefault 0001-01-01T00:00:00+00:00optionalThe date to move. See Datetime input.
inputDateEnter datetime valueDatetimedefault 0001-01-01T00:00:00+00:00optionalThe date to start from. See Datetime input.
daysOfWeekSelect dayWeekDaydefault MONDAYoptionalThe weekday. See Next/Previous weekday.
includeInputIfMatchInclude same day if it matchesBooleandefault falseoptionalSee Next/Previous weekday.
holidayDatesList of holiday datesListdefault []optionalThe holidays. See Next/Previous working date.

Actions

Add (datetimeAdd)

Add time to a date. See Add/Subtract.

Inputs

IdentifierEditor fieldType; required; defaultUse
valTime value to addNumberdefault 0optionalThe amount.
unitTime unit to addUnitdefault DAYSoptionalMILLIS⁠, SECONDS⁠, MINUTES⁠, HOURS⁠, DAYS⁠, WEEKS⁠, MONTHS or YEARS⁠.

Also uses the shared fields: source.

Outputs

IdentifierTypeMeaning
resultDatetimeThe new date.

Example

Set source=2024-01-31T00:00:00+00:00, val=1, unit=MONTHS. Put result in $shifted$.

Expected result

$shifted$ is 2024-02-29T00:00:00+00:00.

Back to actions

Assign (datetimeAssign)

Read a date from text with a named or custom pattern, or copy a Datetime.

Inputs

IdentifierEditor fieldType; required; defaultUse
optionSelect the source datetime variable/ valueOptiondefault constantoptionalconstant⁠: read the text in source⁠. variable⁠: copy dateTime⁠; the format fields are ignored.
sourceEnter the date timeStringdefault ""optionalWith constant⁠: text that matches the format, such as 2011-12-03 for ISO_LOCAL_DATE⁠.
formatTypeSelect date time formatFormatTypedefault preBuiltoptionalWith constant⁠: preBuilt uses preBuiltFormat⁠, custom uses customFormat⁠.
preBuiltFormatpreBuiltFormatPreBuiltFormatdefault ISO_DATE_TIMEoptionalWith constant and preBuilt⁠: a named format from the Prerequisites table.
customFormatcustomFormatStringdefault ""optionalWith constant and custom⁠: a pattern, for example dd/MM/yyyy HH:mm:ss.SSS⁠. See the pattern letters in Prerequisites.
dateTimeSelect the source date time variableDatetimedefault 0001-01-01T00:00:00+00:00optionalWith option=variable only: a Datetime variable or a date with offset.

Outputs

IdentifierTypeMeaning
resultDatetimeThe date and offset.

Example

Set option=constant, source=03/12/2011 10:15:30.250, formatType=custom, customFormat=dd/MM/yyyy HH:mm:ss.SSS. Put result in $when$.

Expected result

$when$ is 2011-12-03T10:15:30.250+00:00. With source=2011-12-03, formatType=preBuilt and preBuiltFormat=ISO_LOCAL_DATE, it is midnight UTC. Text that does not match the pattern fails.

Back to actions

Calculate Datetime Duration (datetimeCalculateDuration)

Get the time between two dates as text. Hours can be more than 24.

Inputs

IdentifierEditor fieldType; required; defaultUse
startDateStart datetimeDatetimedefault 0001-01-01T00:00:00+00:00optionalDatetime input.
endDateEnd datetimeDatetimedefault 0001-01-01T00:00:00+00:00optionalDatetime input.

Outputs

IdentifierTypeMeaning
resultStringThe duration, such as PT26H3M4S⁠: all hours, then minutes and seconds. Zero is PT0S⁠.

Example

Set startDate=2024-03-15T10:00:00+00:00, endDate=2024-03-16T12:03:04+00:00. Put result in $duration$.

Expected result

$duration$ is PT26H3M4S. The same moment gives PT0S. An earlier end gives minus values, for example PT-1H. Parts of a second use a period and up to 9 digits.

Back to actions

Difference between dates (datetimeDifferenceBetweenDates)

Count whole units from source to target. An earlier target gives a negative number.

Inputs

IdentifierEditor fieldType; required; defaultUse
sourceSource Date and time VariableDatetimedefault 0001-01-01T00:00:00+00:00optionalDatetime input.
targetDate and time variable to be comparedDatetimedefault 0001-01-01T00:00:00+00:00optionalDatetime input.
unitTime unitDiffUnitdefault DAYSoptionalCounts whole units only. MONTHS and YEARS follow the calendar (a year is 12 whole months). WEEKS is 7 days. DAYS⁠, HOURS⁠, MINUTES and SECONDS use the elapsed time.

Outputs

IdentifierTypeMeaning
resultNumberThe number of whole units.

Example

Set source=2024-01-01T00:00:00+00:00, target=2024-03-01T00:00:00+00:00, unit=MONTHS. Put result in $difference$.

Expected result

$difference$ is 2. The same dates the other way with unit=DAYS give -60. Less than one unit gives 0. Months count from the source date and its time of day.

Back to actions

First day of month (datetimeFirstDayOfMonth)

Move to the first day of the month. See First/Last day.

Inputs

Uses the shared fields: inputDate (Input datetime).

Outputs

IdentifierTypeMeaning
resultDatetimeThe first day of the month.

Example

Set inputDate=2024-03-15T10:30:00+00:00. Put result in $edge$.

Expected result

$edge$ is 2024-03-01T10:30:00+00:00.

Back to actions

First day of year (datetimeFirstDayOfYear)

Move to the first day of the year. See First/Last day.

Inputs

Uses the shared fields: inputDate (Input datetime).

Outputs

IdentifierTypeMeaning
resultDatetimeThe first day of the year.

Example

Set inputDate=2024-03-15T10:30:00+00:00. Put result in $edge$.

Expected result

$edge$ is 2024-01-01T10:30:00+00:00.

Back to actions

Get (datetimeGet)

Get one part of a date, such as the day or hour, at its offset.

Inputs

IdentifierEditor fieldType; required; defaultUse
sourceDate time variable to get the selected valueDatetimedefault 0001-01-01T00:00:00+00:00optionalDatetime input.
getOptionsDatetime value to getGetOptionsdefault DAYOFMONTHoptionalDAYOFMONTH is 1..31; DAYOFWEEK is Monday=1 through Sunday=7; DAYOFYEAR is 1..365/366. LENGTHOFMONTH is 28..31; LENGTHOFYEAR is 365 or 366. HOUR is 0..23; MINUTE and SECOND are 0..59; MONTH is 1..12; YEAR is the calendar year.

Outputs

IdentifierTypeMeaning
resultNumberThe part you chose.

Example

Set source=2024-02-29T13:45:07+00:00, getOptions=DAYOFWEEK. Put result in $weekday$.

Expected result

$weekday$ is 4 (Thursday). DAYOFYEAR gives 60, and LENGTHOFYEAR gives 366.

Back to actions

Is after (datetimeIsAfter)

Check if source is later than other, with offsets taken into account.

Inputs

Uses the shared fields: source, other.

Outputs

IdentifierTypeMeaning
resultBooleantrue if source is later; otherwise false⁠.

Example

Set source=2024-01-02T00:00:00+00:00, other=2011-12-03T10:15:30+00:00. Put result in $matches$.

Expected result

$matches$ is true. The same moment gives false, also with a different offset.

Back to actions

Is before (datetimeIsBefore)

Check if source is earlier than other, with offsets taken into account.

Inputs

Uses the shared fields: source, other.

Outputs

IdentifierTypeMeaning
resultBooleantrue if source is earlier; otherwise false⁠.

Example

Set source=2024-01-02T00:00:00+00:00, other=2011-12-03T10:15:30+00:00. Put result in $matches$.

Expected result

$matches$ is false. The same moment gives false, also with a different offset.

Back to actions

Is equal (datetimeIsEqual)

Check if two dates are the same moment. The offsets can differ.

Inputs

Uses the shared fields: source, other.

Outputs

IdentifierTypeMeaning
resultBooleantrue for the same moment; otherwise false⁠.

Example

Set source=2011-12-03T10:15:30+00:00, other=2011-12-03T11:15:30+01:00. Put result in $same$.

Expected result

$same$ is true. The same clock time with another offset is a different moment, so it gives false.

Back to actions

Is leap year (datetimeIsLeapYear)

Check if the year of the date is a leap year.

Inputs

IdentifierEditor fieldType; required; defaultUse
sourceDate and time variable to checkDatetimedefault 0001-01-01T00:00:00+00:00optionalDatetime input.

Outputs

IdentifierTypeMeaning
resultBooleantrue for a leap year, using the year at the stored offset.

Example

Set source=2024-02-29T00:00:00+00:00. Put result in $leap$.

Expected result

$leap$ is true. A date in 2023 gives false. Years divisible by 100 are not leap years unless divisible by 400.

Back to actions

Last day of month (datetimeLastDayOfMonth)

Move to the last day of the month. See First/Last day.

Inputs

Uses the shared fields: inputDate (Input datetime).

Outputs

IdentifierTypeMeaning
resultDatetimeThe last day of the month.

Example

Set inputDate=2024-03-15T10:30:00+00:00. Put result in $edge$.

Expected result

$edge$ is 2024-03-31T10:30:00+00:00.

Back to actions

Last day of year (datetimeLastDayOfYear)

Move to the last day of the year. See First/Last day.

Inputs

Uses the shared fields: inputDate (Input datetime).

Outputs

IdentifierTypeMeaning
resultDatetimeThe last day of the year.

Example

Set inputDate=2024-03-15T10:30:00+00:00. Put result in $edge$.

Expected result

$edge$ is 2024-12-31T10:30:00+00:00.

Back to actions

Get Next Day Of Week (datetimeNextDayOfWeek)

Find the next date on a weekday. See Next/Previous weekday.

Inputs

Uses the shared fields: inputDate (Enter datetime value), daysOfWeek, includeInputIfMatch.

Outputs

IdentifierTypeMeaning
resultDatetimeThe date on that weekday.

Example

Set inputDate=2024-03-15T00:00:00+00:00, daysOfWeek=FRIDAY, includeInputIfMatch=false. Put result in $weekday$.

Expected result

$weekday$ is 2024-03-22T00:00:00+00:00. With includeInputIfMatch=true, it stays 2024-03-15T00:00:00+00:00.

Back to actions

Get Next Working Date (datetimeNextWorkingDate)

Find the next working date. See Next/Previous working date.

Inputs

Uses the shared fields: inputDate (Enter datetime value), holidayDates.

Outputs

IdentifierTypeMeaning
resultDatetimeThe next working date, with the same time and offset.

Example

Create $holidays$ as a List with one String item 2024-03-18T00:00:00+00:00. Set inputDate=2024-03-15T00:00:00+00:00, holidayDates=$holidays$. Put result in $working$.

Expected result

$working$ is 2024-03-19T00:00:00+00:00: it skips the weekend and the Monday holiday. With no holidays, it is March 18.

Back to actions

Get Previous Day Of Week (datetimePreviousDayOfWeek)

Find the previous date on a weekday. See Next/Previous weekday.

Inputs

Uses the shared fields: inputDate (Enter datetime value), daysOfWeek, includeInputIfMatch.

Outputs

IdentifierTypeMeaning
resultDatetimeThe date on that weekday.

Example

Set inputDate=2024-03-15T00:00:00+00:00, daysOfWeek=MONDAY, includeInputIfMatch=false. Put result in $weekday$.

Expected result

$weekday$ is 2024-03-11T00:00:00+00:00. With daysOfWeek=FRIDAY and includeInputIfMatch=true, it stays 2024-03-15T00:00:00+00:00.

Back to actions

Get Previous Working Date (datetimePreviousWorkingDate)

Find the previous working date. See Next/Previous working date.

Inputs

Uses the shared fields: inputDate (Enter datetime value), holidayDates.

Outputs

IdentifierTypeMeaning
resultDatetimeThe previous working date, with the same time and offset.

Example

Set inputDate=2024-03-18T00:00:00+00:00 and leave holidayDates empty. Put result in $working$.

Expected result

$working$ is 2024-03-15T00:00:00+00:00, the Friday before. A holiday on March 15 moves it to March 14.

Back to actions

Subtract (datetimeSubtract)

Take time away from a date. See Add/Subtract.

Inputs

IdentifierEditor fieldType; required; defaultUse
valTime value to subtractNumberdefault 0optionalThe amount.
unitTime unit to subtractUnitdefault DAYSoptionalMILLIS⁠, SECONDS⁠, MINUTES⁠, HOURS⁠, DAYS⁠, WEEKS⁠, MONTHS or YEARS⁠.

Also uses the shared fields: source.

Outputs

IdentifierTypeMeaning
resultDatetimeThe new date.

Example

Set source=2024-03-10T06:00:00+00:00, val=36, unit=HOURS. Put result in $shifted$.

Expected result

$shifted$ is 2024-03-08T18:00:00+00:00.

Back to actions

Convert Datetime To Epoch (datetimeToEpoch)

Change a date to Unix epoch seconds (seconds since 1 Jan 1970 UTC), not milliseconds.

Inputs

Uses the shared fields: inputDate (Enter datetime value).

Outputs

IdentifierTypeMeaning
resultNumberWhole seconds since 1970-01-01T00:00:00+00:00⁠.

Example

Set inputDate=1970-01-01T00:01:00+00:00. Put result in $epoch$.

Expected result

$epoch$ is Number 60. The same moment with another offset gives the same number. Parts of a second are dropped (rounded down). Dates before 1970 give negative numbers.

Back to actions

To string (datetimeToString)

Write a date as text with a named or custom pattern.

Inputs

IdentifierEditor fieldType; required; defaultUse
selectPatternSelect date time formatSelectPatterndefault PREBUILToptionalPREBUILT uses preBuiltPattern⁠; CUSTOM uses patternInput⁠.
preBuiltPatternpreBuiltPatternPreBuiltPatterndefault ISO_DATE_TIMEoptionalWith PREBUILT⁠: a named format from the Prerequisites table.
patternInputpatternInputStringdefault ""optionalWith CUSTOM⁠: a pattern, for example yyyy/MM/dd HH:mm:ss.SSS a⁠. It uses the stored offset.

Also uses the shared fields: source.

Outputs

IdentifierTypeMeaning
resultStringThe date as text.

Example

Set source=2011-12-03T10:15:30+00:00, selectPattern=CUSTOM, patternInput=yyyy/MM/dd HH:mm:ss.SSS a. Put result in $text$.

Expected result

$text$ is 2011/12/03 10:15:30.000 AM. PREBUILT with ISO_LOCAL_DATE_TIME gives 2011-12-03T10:15:30. A custom pattern shows the parts of a second you ask for. A bad pattern can fail.

Back to actions

Conditions

Date condition (datetimeCondition)

Compare two dates in an If or Loop. Offsets are taken into account.

Inputs

IdentifierEditor fieldType; required; defaultUse
sourceSource valueDatetimedefault 0001-01-01T00:00:00+00:00requiredDatetime input.
operatorOperatorOperatordefault EQoptionalChoose EQ (=), NEQ (≠), GT (>), GTE (≥), LT (<), or LTE (≤).
targetTarget valueDatetimedefault 0001-01-01T00:00:00+00:00requiredDatetime input.

Outputs

None. The condition is true for a match, otherwise false.

Example

On an If step, set source=2011-12-03T10:15:30+00:00, operator=LT, target=2011-12-25T00:00:00+00:00.

Expected result

The condition is true. GT gives false. The same moment is equal across different offsets. Read text that is not ISO with Assign first.

Back to conditions