Date Connector

The Date Connector provides a comprehensive set of date and time operations for formatting, parsing, arithmetic, and comparison. ***

Date Connector

The Date Connector provides a comprehensive set of date and time operations for formatting, parsing, arithmetic, and comparison.


Available Units

Many operations accept a unit parameter. The following units are supported (from Moment.js):

UnitShorthandDescription
yearsyYear
quartersQQuarter (3-month period)
monthsMMonth
weekswWeek
daysdDay
hourshHour
minutesmMinute
secondssSecond
millisecondsmsMillisecond

Note: Both singular (year, day) and plural (years, days) forms are accepted.

Unit Usage by Operation

OperationSupported UnitsDefault
addAll unitsdays
subtractAll unitsdays
diffAll unitsdays
startOfyear, quarter, month, week, day, hour, minute, secondday
endOfyear, quarter, month, week, day, hour, minute, secondday
rangeAll unitsdays
isBeforeAll units (optional granularity)-
isAfterAll units (optional granularity)-
isBetweenAll units (optional granularity)-

Operations


now

Returns the current date and time.

Parameters

ParameterTypeRequiredDefaultDescription
formatstringNoISO8601Output format (e.g., YYYY-MM-DD, MM/DD/YYYY)

Examples

// Input
{ "operation": "now", "data": {} }

// Output
{ "result": "2024-01-15T10:30:00.000Z" }
// Input with format
{ "operation": "now", "data": { "format": "YYYY-MM-DD" } }

// Output
{ "result": "2024-01-15" }

format

Formats a date into a specified string format.

Parameters

ParameterTypeRequiredDefaultDescription
datestringYes-The date to format
formatstringNoYYYY-MM-DDThe output format

Examples

// Input
{ "operation": "format", "data": { "date": "2024-01-15T10:30:00Z", "format": "MMMM Do, YYYY" } }

// Output
{ "result": "January 15th, 2024" }

parse

Parses a date string from one format to another.

Parameters

ParameterTypeRequiredDefaultDescription
datestringYes-The date string to parse
inputFormatstringNoAuto-detectThe format of the input date
outputFormatstringNoYYYY-MM-DDThe desired output format

Examples

// Input
{ "operation": "parse", "data": { "date": "15/01/2024", "inputFormat": "DD/MM/YYYY", "outputFormat": "YYYY-MM-DD" } }

// Output
{ "result": "2024-01-15" }

add

Adds a specified amount of time to a date.

Parameters

ParameterTypeRequiredDefaultDescription
datestringYes-The starting date
amountnumberNo0The amount to add
unitstringNodaysThe unit (see Available Units)
formatstringNoISO8601Output format

Examples

// Add 7 days
{ "operation": "add", "data": { "date": "2024-01-15", "amount": 7, "unit": "days", "format": "YYYY-MM-DD" } }

// Output
{ "result": "2024-01-22" }
// Add 2 weeks
{ "operation": "add", "data": { "date": "2024-01-15", "amount": 2, "unit": "weeks", "format": "YYYY-MM-DD" } }

// Output
{ "result": "2024-01-29" }
// Add 3 months
{ "operation": "add", "data": { "date": "2024-01-15", "amount": 3, "unit": "months", "format": "YYYY-MM-DD" } }

// Output
{ "result": "2024-04-15" }

subtract

Subtracts a specified amount of time from a date.

Parameters

ParameterTypeRequiredDefaultDescription
datestringYes-The starting date
amountnumberNo0The amount to subtract
unitstringNodaysThe unit (see Available Units)
formatstringNoISO8601Output format

Examples

// Subtract 1 month
{ "operation": "subtract", "data": { "date": "2024-01-15", "amount": 1, "unit": "months", "format": "YYYY-MM-DD" } }

// Output
{ "result": "2023-12-15" }
// Subtract 1 year
{ "operation": "subtract", "data": { "date": "2024-01-15", "amount": 1, "unit": "years", "format": "YYYY-MM-DD" } }

// Output
{ "result": "2023-01-15" }
// Subtract 6 hours
{ "operation": "subtract", "data": { "date": "2024-01-15T12:00:00Z", "amount": 6, "unit": "hours" } }

// Output
{ "result": "2024-01-15T06:00:00.000Z" }

diff

Calculates the difference between two dates.

Parameters

ParameterTypeRequiredDefaultDescription
startDatestringYes-The start date
endDatestringYes-The end date
unitstringNodaysThe unit (see Available Units)
precisebooleanNofalseWhether to return a floating-point value

Examples

// Difference in days
{ "operation": "diff", "data": { "startDate": "2024-01-01", "endDate": "2024-01-15", "unit": "days" } }

// Output
{ "result": 14 }
// Difference in months
{ "operation": "diff", "data": { "startDate": "2024-01-01", "endDate": "2024-06-01", "unit": "months" } }

// Output
{ "result": 5 }
// Precise difference in days
{ "operation": "diff", "data": { "startDate": "2024-01-01", "endDate": "2024-01-15T12:00:00Z", "unit": "days", "precise": true } }

// Output
{ "result": 14.5 }
// Difference in hours
{ "operation": "diff", "data": { "startDate": "2024-01-15T08:00:00Z", "endDate": "2024-01-15T17:30:00Z", "unit": "hours", "precise": true } }

// Output
{ "result": 9.5 }

isBefore

Checks if a date is before another date.

Parameters

ParameterTypeRequiredDefaultDescription
datestringYes-The date to check
compareDatestringYes-The date to compare against
unitstringNo-Granularity (see Available Units)

Examples

// Basic comparison
{ "operation": "isBefore", "data": { "date": "2024-01-01", "compareDate": "2024-01-15" } }

// Output
{ "result": true }
// Compare at month granularity (same month = false)
{ "operation": "isBefore", "data": { "date": "2024-01-15", "compareDate": "2024-01-01", "unit": "month" } }

// Output
{ "result": false }

isAfter

Checks if a date is after another date.

Parameters

ParameterTypeRequiredDefaultDescription
datestringYes-The date to check
compareDatestringYes-The date to compare against
unitstringNo-Granularity (see Available Units)

Examples

// Basic comparison
{ "operation": "isAfter", "data": { "date": "2024-01-15", "compareDate": "2024-01-01" } }

// Output
{ "result": true }
// Compare at year granularity
{ "operation": "isAfter", "data": { "date": "2024-06-15", "compareDate": "2023-12-31", "unit": "year" } }

// Output
{ "result": true }

isBetween

Checks if a date falls between two other dates.

Parameters

ParameterTypeRequiredDefaultDescription
datestringYes-The date to check
startDatestringYes-The range start date
endDatestringYes-The range end date
unitstringNo-Granularity (see Available Units)
inclusivitystringNo[]Inclusivity mode (see below)

Inclusivity Options:

ValueDescription
()Excludes both start and end
[]Includes both start and end (default)
[)Includes start, excludes end
(]Excludes start, includes end

Examples

// Inclusive check (default)
{ "operation": "isBetween", "data": { "date": "2024-01-10", "startDate": "2024-01-01", "endDate": "2024-01-31" } }

// Output
{ "result": true }
// Exclusive check
{ "operation": "isBetween", "data": { "date": "2024-01-01", "startDate": "2024-01-01", "endDate": "2024-01-31", "inclusivity": "()" } }

// Output
{ "result": false }

startOf

Gets the start of a time unit for a given date.

Parameters

ParameterTypeRequiredDefaultDescription
datestringYes-The date
unitstringNodayThe unit (see Available Units)
formatstringNoISO8601Output format

Examples

// Start of month
{ "operation": "startOf", "data": { "date": "2024-01-15T14:30:00Z", "unit": "month", "format": "YYYY-MM-DD" } }

// Output
{ "result": "2024-01-01" }
// Start of year
{ "operation": "startOf", "data": { "date": "2024-06-15", "unit": "year", "format": "YYYY-MM-DD" } }

// Output
{ "result": "2024-01-01" }
// Start of week
{ "operation": "startOf", "data": { "date": "2024-01-15", "unit": "week", "format": "YYYY-MM-DD" } }

// Output
{ "result": "2024-01-14" }
// Start of day
{ "operation": "startOf", "data": { "date": "2024-01-15T14:30:00Z", "unit": "day", "format": "YYYY-MM-DD HH:mm:ss" } }

// Output
{ "result": "2024-01-15 00:00:00" }

endOf

Gets the end of a time unit for a given date.

Parameters

ParameterTypeRequiredDefaultDescription
datestringYes-The date
unitstringNodayThe unit (see Available Units)
formatstringNoISO8601Output format

Examples

// End of month
{ "operation": "endOf", "data": { "date": "2024-01-15", "unit": "month", "format": "YYYY-MM-DD HH:mm:ss" } }

// Output
{ "result": "2024-01-31 23:59:59" }
// End of year
{ "operation": "endOf", "data": { "date": "2024-06-15", "unit": "year", "format": "YYYY-MM-DD" } }

// Output
{ "result": "2024-12-31" }
// End of quarter
{ "operation": "endOf", "data": { "date": "2024-02-15", "unit": "quarter", "format": "YYYY-MM-DD" } }

// Output
{ "result": "2024-03-31" }

fromNow

Returns a human-readable relative time string from now.

Parameters

ParameterTypeRequiredDefaultDescription
datestringYes-The date to compare
withoutSuffixbooleanNofalseRemove the "ago"/"in" suffix

Examples

// Past date (assuming current date is 2024-01-15)
{ "operation": "fromNow", "data": { "date": "2024-01-10" } }

// Output
{ "result": "5 days ago" }
// Future date
{ "operation": "fromNow", "data": { "date": "2024-01-20" } }

// Output
{ "result": "in 5 days" }
// Without suffix
{ "operation": "fromNow", "data": { "date": "2024-01-20", "withoutSuffix": true } }

// Output
{ "result": "5 days" }

range

Generates an array of dates between a start and end date.

Parameters

ParameterTypeRequiredDefaultDescription
startDatestringYes-The range start date
endDatestringYes-The range end date
unitstringNodaysThe unit (see Available Units)
stepnumberNo1The step increment
formatstringNoISO8601Output format for each date

Examples

// Daily range
{ "operation": "range", "data": { "startDate": "2024-01-01", "endDate": "2024-01-05", "unit": "days", "format": "YYYY-MM-DD" } }

// Output
{ "result": ["2024-01-01", "2024-01-02", "2024-01-03", "2024-01-04", "2024-01-05"] }
// Weekly range
{ "operation": "range", "data": { "startDate": "2024-01-01", "endDate": "2024-01-31", "unit": "weeks", "format": "YYYY-MM-DD" } }

// Output
{ "result": ["2024-01-01", "2024-01-08", "2024-01-15", "2024-01-22", "2024-01-29"] }
// Monthly range
{ "operation": "range", "data": { "startDate": "2024-01-01", "endDate": "2024-06-01", "unit": "months", "format": "MMMM YYYY" } }

// Output
{ "result": ["January 2024", "February 2024", "March 2024", "April 2024", "May 2024", "June 2024"] }
// Every 2 days
{ "operation": "range", "data": { "startDate": "2024-01-01", "endDate": "2024-01-10", "unit": "days", "step": 2, "format": "YYYY-MM-DD" } }

// Output
{ "result": ["2024-01-01", "2024-01-03", "2024-01-05", "2024-01-07", "2024-01-09"] }

filterBetween

Filters a collection of objects to include only items where the date at the specified path falls between the start and end dates.

Parameters

ParameterTypeRequiredDefaultDescription
collectionarrayYes-The array of objects to filter
datePathstringYes-Path to the date property (dot notation supported)
startDatestringYes-The range start date
endDatestringYes-The range end date
inclusivitystringNo[]Inclusivity mode (see below)

Inclusivity Options:

ValueDescription
()Excludes both start and end
[]Includes both start and end (default)
[)Includes start, excludes end
(]Excludes start, includes end

Examples

// Filter appointments within a time range (inclusive)
{
  "operation": "filterBetween",
  "data": {
    "collection": [
      { "durationMinutes": 15, "appointmentDateTimeLocal": "2026-01-24T09:00-08:00" },
      { "durationMinutes": 15, "appointmentDateTimeLocal": "2026-01-24T09:15-08:00" },
      { "durationMinutes": 15, "appointmentDateTimeLocal": "2026-01-24T09:30-08:00" },
      { "durationMinutes": 15, "appointmentDateTimeLocal": "2026-01-24T09:45-08:00" },
      { "durationMinutes": 15, "appointmentDateTimeLocal": "2026-01-24T10:00-08:00" }
    ],
    "datePath": "appointmentDateTimeLocal",
    "startDate": "2026-01-24T09:15-08:00",
    "endDate": "2026-01-24T09:45-08:00"
  }
}

// Output
{
  "result": [
    { "durationMinutes": 15, "appointmentDateTimeLocal": "2026-01-24T09:15-08:00" },
    { "durationMinutes": 15, "appointmentDateTimeLocal": "2026-01-24T09:30-08:00" },
    { "durationMinutes": 15, "appointmentDateTimeLocal": "2026-01-24T09:45-08:00" }
  ]
}
// Filter with exclusive bounds
{
  "operation": "filterBetween",
  "data": {
    "collection": [
      { "durationMinutes": 15, "appointmentDateTimeLocal": "2026-01-24T09:00-08:00" },
      { "durationMinutes": 15, "appointmentDateTimeLocal": "2026-01-24T09:15-08:00" },
      { "durationMinutes": 15, "appointmentDateTimeLocal": "2026-01-24T09:30-08:00" }
    ],
    "datePath": "appointmentDateTimeLocal",
    "startDate": "2026-01-24T09:00-08:00",
    "endDate": "2026-01-24T09:30-08:00",
    "inclusivity": "()"
  }
}

// Output
{
  "result": [
    { "durationMinutes": 15, "appointmentDateTimeLocal": "2026-01-24T09:15-08:00" }
  ]
}
// Filter with nested date path
{
  "operation": "filterBetween",
  "data": {
    "collection": [
      { "id": 1, "schedule": { "startTime": "2026-01-24T09:00-08:00" } },
      { "id": 2, "schedule": { "startTime": "2026-01-24T09:30-08:00" } },
      { "id": 3, "schedule": { "startTime": "2026-01-24T10:00-08:00" } }
    ],
    "datePath": "schedule.startTime",
    "startDate": "2026-01-24T09:00-08:00",
    "endDate": "2026-01-24T09:30-08:00"
  }
}

// Output
{
  "result": [
    { "id": 1, "schedule": { "startTime": "2026-01-24T09:00-08:00" } },
    { "id": 2, "schedule": { "startTime": "2026-01-24T09:30-08:00" } }
  ]
}
// Filter with inclusive start, exclusive end [)
{
  "operation": "filterBetween",
  "data": {
    "collection": [
      { "id": 1, "date": "2026-01-24T09:00-08:00" },
      { "id": 2, "date": "2026-01-24T09:15-08:00" },
      { "id": 3, "date": "2026-01-24T09:30-08:00" }
    ],
    "datePath": "date",
    "startDate": "2026-01-24T09:00-08:00",
    "endDate": "2026-01-24T09:30-08:00",
    "inclusivity": "[)"
  }
}

// Output
{
  "result": [
    { "id": 1, "date": "2026-01-24T09:00-08:00" },
    { "id": 2, "date": "2026-01-24T09:15-08:00" }
  ]
}

Using with Context Variables

When using context variables with LiquidJS templates, arrays and objects require special handling.

⚠️

Important: Do not wrap array/object variables in quotes. Use the | json filter to properly serialize them.

❌ Incorrect - Produces [object Object] strings:

{
  "operation": "filterBetween",
  "data": {
    "collection": "{{context.data.availableAppointments}}",
    "datePath": "appointmentDateTimeLocal",
    "startDate": "{{context.selectedDate}}T{{context.startTime}}",
    "endDate": "{{context.selectedDate}}T{{context.endTime}}",
    "inclusivity": "[]"
  }
}

When rendered, this produces invalid output because LiquidJS converts the array to a string:

{
  "collection": "[object Object][object Object][object Object]...",
  "datePath": "appointmentDateTimeLocal",
  "startDate": "2026-01-28T08:00:00",
  "endDate": "2026-01-28T11:00:00",
  "inclusivity": "[]"
}

✅ Correct - Use | json filter without quotes:

{
  "operation": "filterBetween",
  "data": {
    "collection": {{ context.data.availableAppointments | json }},
    "datePath": "appointmentDateTimeLocal",
    "startDate": "{{ context.selectedDate }}T{{ context.startTime }}",
    "endDate": "{{ context.selectedDate }}T{{ context.endTime }}",
    "inclusivity": "[]"
  }
}

Why this works:

  • The | json filter serializes the array/object to a valid JSON string
  • Omitting the surrounding quotes allows the JSON array to be inserted directly as a value
  • String variables (like dates) should still use quotes: "{{ context.selectedDate }}"

General rule for LiquidJS templates in connector configs:

Variable TypeSyntaxExample
String"{{ variable }}""startDate": "{{ context.selectedDate }}"
Array/Object{{ variable | json }}"collection": {{ context.items | json }}
Number{{ variable }}"amount": {{ context.count }}
Boolean{{ variable }}"precise": {{ context.usePrecise }}

Notes

  • Items with missing date properties are excluded from the result
  • Items with invalid/unparseable dates are excluded from the result
  • The datePath parameter supports dot notation for nested properties (e.g., schedule.startTime)
  • Throws an error if collection is not an array

isValid

Checks if a date string is valid.

Parameters

ParameterTypeRequiredDefaultDescription
datestringYes-The date string to validate
formatstringNoAuto-detectExpected format for strict parsing

Examples

// Valid ISO date
{ "operation": "isValid", "data": { "date": "2024-01-15" } }

// Output
{ "result": true }
// Invalid date
{ "operation": "isValid", "data": { "date": "not-a-date" } }

// Output
{ "result": false }
// Strict format validation
{ "operation": "isValid", "data": { "date": "15/01/2024", "format": "DD/MM/YYYY" } }

// Output
{ "result": true }
// Wrong format (strict mode fails)
{ "operation": "isValid", "data": { "date": "2024-01-15", "format": "DD/MM/YYYY" } }

// Output
{ "result": false }

Common Format Tokens

TokenDescriptionExample
YYYY4-digit year2024
YY2-digit year24
QQuarter1-4
MMMonth (zero-padded)01-12
MMonth1-12
MMMMonth abbreviationJan, Feb
MMMMFull month nameJanuary
DDDay (zero-padded)01-31
DDay1-31
DoDay with ordinal1st, 2nd, 15th
ddddDay of weekMonday
dddDay abbreviationMon
HHHour 24h (padded)00-23
HHour 24h0-23
hhHour 12h (padded)01-12
hHour 12h1-12
mmMinutes (padded)00-59
mMinutes0-59
ssSeconds (padded)00-59
sSeconds0-59
AAM/PMAM, PM
aam/pmam, pm
XUnix timestamp (sec)1705312200
xUnix timestamp (ms)1705312200000