On This Page

Date and Time Functions

Functions for extracting date/time components and performing date arithmetic.

Working with Timestamps

In ProcessMind, timestamps are stored as numbers representing milliseconds since January 1, 1970 (Unix epoch). The date functions work with these timestamp values.

Common Patterns

  • Extract date parts:

    year(StartTime)       // 2024
    month(StartTime)      // 3 (March)
    day(StartTime)        // 15
  • Calculate duration:

    dateDiff(StartTime, EndTime, "minute")
    dateDiff(StartTime, EndTime, "hour")
    dateDiff(StartTime, EndTime, "day")
  • Create time buckets:

    bucket(hour(StartTime), 6, "Night", 12, "Morning", 18, "Afternoon", "Evening")
  • Add time to a date:

    dateAdd(StartTime, 7, "day")     // Add 7 days
    dateAdd(StartTime, -1, "month")  // Subtract 1 month

now

()

Returns the current UTC timestamp, in milliseconds since the Unix epoch.

Returns number
Examples
now() 1708963200000

Current timestamp

year

(timestamp)

Extracts the year from a timestamp.

Parameters
timestamp number The timestamp value
Returns number
Examples
year(StartTime) 2024
See Also

month

(timestamp)

Extracts the month, 1-12, from a timestamp.

Parameters
timestamp number The timestamp value
Returns number
Examples
month(StartTime) 3

March

See Also

day

(timestamp)

Extracts the day of the month, 1-31, from a timestamp.

Parameters
timestamp number The timestamp value
Returns number
Examples
day(StartTime) 18
See Also

hour

(timestamp)

Extracts the hour, 0-23, from a timestamp.

Parameters
timestamp number The timestamp value
Returns number
Examples
hour(StartTime) 14

2 PM

See Also

minute

(timestamp)

Extracts the minute, 0-59, from a timestamp.

Parameters
timestamp number The timestamp value
Returns number
Examples
minute(StartTime) 30
See Also

second

(timestamp)

Extracts the second, 0-59, from a timestamp.

Parameters
timestamp number The timestamp value
Returns number
Examples
second(StartTime) 45
See Also

dayOfWeek

(timestamp)

Returns the day of the week, 1=Monday and 7=Sunday, from a timestamp.

Parameters
timestamp number The timestamp value
Returns number
Examples
dayOfWeek(StartTime) 1

Monday

See Also

dayName

(timestamp)

Returns the day of the week by name from a timestamp.

Parameters
timestamp number The timestamp value
Returns string
Examples
dayName(StartTime) Monday
See Also

monthName

(timestamp)

Returns the month name from a timestamp.

Parameters
timestamp number The timestamp value
Returns string
Examples
monthName(StartTime) March
See Also

quarter

(timestamp)

Returns the quarter, 1-4, from a timestamp.

Parameters
timestamp number The timestamp value
Returns number
Examples
quarter(StartTime) 1

Q1 (Jan-Mar)

See Also

weekOfYear

(timestamp)

Returns the ISO week number, 1-53, from a timestamp.

Parameters
timestamp number The timestamp value
Returns number
Examples
weekOfYear(StartTime) 12

Week 12 of 2024

See Also

dayOfYear

(timestamp)

Returns the day of the year, 1-366, from a timestamp.

Parameters
timestamp number The timestamp value
Returns number
Examples
dayOfYear(StartTime) 78

78th day of the year (March 18, 2024)

See Also

dateAdd

(timestamp, amount, unit)

Adds a specified amount of time to a timestamp.

Parameters
timestamp number The starting timestamp
amount number The amount to add, which can be negative
unit string The unit: 'year', 'month', 'day', 'hour', 'minute', 'second'
Returns number
Examples
dateAdd(StartTime, 7, "day") timestamp + 7 days
dateAdd(StartTime, -1, "month") timestamp - 1 month
dateAdd(1710766245000, 1, "day") 1710852645000

Add 1 day to March 18, 2024

See Also

dateDiff

(startTimestamp, endTimestamp, unit)

Calculates the difference between two timestamps in the specified unit.

Parameters
startTimestamp number The start timestamp
endTimestamp number The end timestamp
unit string The unit: 'day', 'hour', 'minute', 'second'
Returns number
Examples
dateDiff(StartTime, EndTime, "minute") 150

Duration in minutes

dateDiff(StartTime, EndTime, "hour") 2.5
Notes

Returns a decimal value representing the exact difference.

See Also

isBusinessDay

(timestamp)

Checks whether a timestamp falls on a business day, Monday through Friday.

Parameters
timestamp number The timestamp to check
Returns boolean
Examples
isBusinessDay(StartTime) true

If StartTime is a weekday

See Also

workingDaysBetween

(startTimestamp, endTimestamp)

Counts the business days, Monday through Friday, between two timestamps.

Parameters
startTimestamp number The start timestamp
endTimestamp number The end timestamp
Returns number
Examples
workingDaysBetween(StartTime, EndTime) Number of weekdays between the dates
workingDaysBetween(1710766245000, 1711371045000) 5

5 working days between Mon Mar 18 and Mon Mar 25, 2024

Notes

Approximate backend/business-calendar helper. It does not account for holidays, only weekends.

See Also

toUtc

(timestamp, offsetHours)

Converts a local timestamp to UTC by subtracting the offset.

Parameters
timestamp number The local timestamp
offsetHours number The timezone offset in hours
Returns number
Examples
toUtc(StartTime, 2) StartTime - 2 hours

Convert from UTC+2

toUtc(1710766245000, 2) 1710759045000

Convert timestamp from UTC+2 to UTC

Notes

Timezone conversion currently supports numeric UTC offsets in hours, not IANA timezone names.

See Also

toLocal

(timestamp, offsetHours)

Converts a UTC timestamp to local time by adding the offset.

Parameters
timestamp number The UTC timestamp
offsetHours number The timezone offset in hours
Returns number
Examples
toLocal(StartTime, -5) StartTime - 5 hours

Convert to EST

toLocal(1710766245000, -5) 1710748245000

Convert UTC timestamp to EST (UTC-5)

Notes

Timezone conversion currently supports numeric UTC offsets in hours, not IANA timezone names.

See Also

convertTimezone

(timestamp, fromOffset, toOffset)

Converts a timestamp from one timezone to another.

Parameters
timestamp number The timestamp to convert
fromOffset number Source timezone offset in hours
toOffset number Target timezone offset in hours
Returns number
Examples
convertTimezone(StartTime, 1, -5) timestamp adjusted -6 hours

CET to EST

convertTimezone(1710766245000, 1, -5) 1710744645000

Convert from UTC+1 to UTC-5

Notes

Timezone conversion currently supports numeric UTC offsets in hours, not IANA timezone names.

See Also