Last updated: 2025-08-14

Source: https://support.freshservice.com/support/solutions/articles/50000004102-functions-in-expression-builder-node

The expression builder node supports a whole host of functions that you can use to perform string, mathematical, conditional, and date operations on values from the workflow context.

String Functions

1) charAt(Text text, Number index)

HeaderValue
Return TypeString
SyntaxcharAt(‘text1’, specifiedindex)
DescriptionReturns the character at the specified index from the given text1.
Example1. charAt('Freshservice', 0)<br> <br> Result: 'F'<br> <br>2. charAt('Freshservice', 1)<br> <br>            Result: 'r'

2) compareTo(Text text1, Text text2)

HeaderValue
Return TypeNumber
SyntaxcompareTo(‘text1’,‘text2’)
DescriptionCompares text1 and text2  based on their position in the dictionary. This function is case-sensitive.<br>0, if text1= text2<br>Positive value, if text1>text2<br>Negative value,  if text1<text2
Example1. compareTo('aaa', 'aaa')<br> <br>Result:0<br>2. compareTo('aaa', 'AAA')<br> <br>Result: 32

3) compareToIgnoreCase(Text text1, Text text2)

HeaderValue
Return TypeNumber
SyntaxcompareToIgnoreCase(‘text1’,‘text2’)
DescriptionCompares text1 and text2 based on their position in the dictionary. This function is not case-sensitive.<br>0, if text1= text2<br>Positive value, if text1>text2<br>Negative value,  if text1<text2
Example1. compareToIgnoreCase('aaa', 'AAA')<br> <br>Result: 0<br>2. compareToIgnoreCase('aaa', 'aaa’')<br> <br>Result: 0

4)  concat(Text text1, Text text2)

HeaderValue
Return TypeString
Syntaxconcat(‘text1’, ‘text2’)
DescriptionCombines text1 and text2.
Example1. concat('aaa', 'AAA')<br> <br>Result: aaaAAA

5)endsWith(Text text, Text suffix)

HeaderValue
Return TypeBoolean (true,false)
SyntaxendsWith(‘text’, ‘suffix’)
DescriptionChecks if text ends with the given specific characters.
Example1. endsWith('freshservice', 'vice')<br> <br>Result: true<br>2. endsWith('freshservice', 'abc')<br> <br> Result: false

6) equals(Text text1, Text text2)

HeaderValue
Return TypeBoolean (true,false)
SyntaxendsWith(‘text1’, ‘ text2’)
DescriptionChecks if text1 and text2 match. This function is case-sensitive
Example1. equals('freshservice', 'freshservice')<br> <br>Result: true<br>2. equals('freshservice', 'FRESHSERVICE')<br> <br> Result: false

7)  equalsIgnoreCase(Text text1, Text text2)

HeaderValue
Return TypeBoolean (true,false)
SyntaxequalsIgnoreCase(‘text1’, ‘ text2’)
DescriptionChecks if text1 and text2 match.This function is not case-sensitive
Example1. equalsIgnoreCase('freshservice', 'freshservice')<br> <br>Result: true<br>2. equalsIgnoreCase('freshservice', 'FRESHSERVICE')<br> <br>Result: true

8) indexOf(Text text1, Text text2, Number fromIndex)

HeaderValue
Return TypeNumber
SyntaxindexOf(‘text1’, ‘text2’, fromIndex)
DescriptionFinds where text2 first occurs within text1 while searching forwards from a specified index.
Example1. indexOf('freshservice', 'es', 0)<br> <br>Result: 2<br>2. indexOf('freshservice', 'er', 3)<br> <br> Result: 6

9)  lastIndexOf(Text text1, Text text2, Number fromIndex)

HeaderValue
Return TypeNumber
SyntaxlastIndexOf(‘text1’, ‘text2’, fromIndex)
DescriptionFinds where the text2 last occurs within text1 while searching backwards from a specified index.
Example1. lastIndexOf('freshservice', 'es', 3)<br> <br>Result: 2<br>2. lastIndexOf('freshworks', 'rk', 8)<br> <br> Result: 7

10) length(Text text)

HeaderValue
Return TypeNumber
Syntaxlength(‘text’)
DescriptionReturns the number of characters in a given text.
Example1.  length('freshservice')<br> <br>Result: 12

11) replace(Text text, Text oldText, Text newText)

HeaderValue
Return TypeString
Syntaxreplace(‘text’, ‘oldtext’, ‘newtext’)
DescriptionReturns a text,replacing all occurrences of oldtext with newtext.
Example1. replace('freshservice', 'service', 'works')<br> <br> Result: freshworks

12) startsWith(Text text, Text prefix, Number fromIndex)

HeaderValue
Return TypeBoolean (true, false)
SyntaxstartsWith( ‘text’, ‘prefix’,fromIndex)
DescriptionChecks if the text starts with a specified prefix,based on the provided fromindex.
Example1.  startsWith('freshservice', 'fres', 0)<br> <br>Result: true<br>II.       startsWith('freshservice', 'fres', 2)<br>             Result: false

13)  substring(Text text, Number fromIndex, Number toIndex)

HeaderValue
Return TypeString
Syntaxsubstring( ‘text’, fromIndex, toIndex)
DescriptionReturns the truncated text starting at the fromIndex and ending at the toIndex<br>length of the text: endIndex-beginIndex
Example1. substring('freshservice', 0, 1)<br> <br> Result: f<br> <br>2. substring('freshservice', 0, 3)<br> <br> Result: fre

14)  toLowerCase(Text text)

HeaderValue
Return TypeString
SyntaxtoLowerCase(‘text’)
DescriptionConverts all of the characters in a text to lowercase.
Example1. toLowerCase('FRESHSERVICE')<br> <br>Result: freshservice

15) toUpperCase(Text text)

HeaderValue
Return TypeString
SyntaxtoUpperCase(‘text’)
DescriptionConverts all of the characters in a text to upper case.
Example1. toUpperCase('freshservice')<br> <br> Result: FRESHSERVICE

16) trim(Text text)

HeaderValue
Return TypeString
Syntaxtrim(‘text’)
DescriptionRemoves whitespace from both ends of a text.
Example1. trim('  freshservice  ')<br> <br> Result: freshservice

17) regexMatch(Text text, Text pattern)

HeaderValue
Return TypeBoolean (true, false)
SyntaxregexMatch( “text”,  “pattern”)
DescriptionChecks if the text contains the pattern
Example1.  regexMatch("a", "\[amn\]?" )<br> <br> Result: true

18)  regexReplace(Text text, Text pattern, Text newText)

HeaderValue
Return TypeString
SyntaxregexReplace(“text”, “pattern”, “new text”)
DescriptionReturns a new string by replacing the pattern in text with newText
Example1. regexReplace("My name is Khan. My name is Bob. My name is Sonoo.", "is", "was" )<br> <br> Result: My name was Khan. My name was Bob. My name was Sonoo

19)  intOf('text1')

HeaderValue
Return TypeInteger
SyntaxintOf(‘text1’)
DescriptionReturns the integer value for the string.<br>Return Type: Integer<br>Syntax<br>IntOf ('value 1')<br>Note: The value 1 here is a string.
ExampleIntOf('120')<br>Result will be 120

Mathematical Functions

1) abs(Decimal value)

HeaderValue
Return TypeNumber
Syntaxabs(value)
DescriptionRemoves the negative sign for a given value and returns an absolute number.
Example1. abs(3.14)<br> <br>Result: 3.14<br>2. abs(-3.14)<br> <br> Result: 3.14

2) acos(Decimal value)

HeaderValue
Return TypeNumber
Syntaxacos(value)
DescriptionReturns the arc cosine of the given value.<br>Returned value range: 0.0 through PI.
Example1. acos(-0.45)<br> <br> Result: 2<br> <br>2. acos(0.45)<br> <br> Result: 1

3) asin(Decimal value)

HeaderValue
Return TypeNumber
Syntaxasin(value)
DescriptionReturns the arc sine of the given value.<br>Returned value range:  -PI/2 through PI/2.
Example1.  asin(1)<br> <br>Result:1<br>2.  asin(0.789)<br> <br>Result: 0

4) atan(Decimal value)

HeaderValue
Return TypeNumber
Syntaxatan(value)
DescriptionReturns the arc tangent of the given value.<br>Returned value range:  -PI/2 through PI/2.
Example1. atan(1)<br> <br> Result: 0<br> <br>2. atan(1000)<br> <br>Result: 1

5) atan2(Decimal x, Decimal y)

HeaderValue
Return TypeNumber
Syntaxatan2( x, y)
DescriptionReturns the angle in radians between the X-axis and a line passing though (x,y) and the origin (0,0)
Example1.  atan2(1,1)<br> <br>  Result: 0.7853981633974483<br> <br>2.  atan2(4,3)<br> <br>  Result: 0.9272952180016122

6) ceil(Decimal value)

HeaderValue
Return TypeNumber
Syntaxceil(value)
DescriptionRounds up to the smallest integer that is greater than or equal to a given value.
Example1.  ceil(1.583)<br> <br>Result: 2<br>2.  ceil(-10.328)<br> <br>Result: 10

7) cos(Decimal value)

HeaderValue
Return TypeNumber
Syntaxcos(value)
DescriptionReturns the trigonometric cosine of an angle.
Example1. cos(1.5707963267948966)<br> <br>Result: 0<br>2. cos(0)<br> <br> Result: 1

8) exp(Decimal value)

HeaderValue
Return TypeNumber
Syntaxexp(value)
DescriptionReturns Euler's number, e (~2.718) raised to a power.
Example1. exp(10)<br> <br> Result: 22026.465794806718<br> <br>2. exp(-9)<br> <br>Result: 0.00012340980408667956

9) floor(Decimal value)

HeaderValue
Return TypeNumber
Syntaxfloor(value)
DescriptionRounds up to the greatest integer that is less than or equal to a given value.
Example1. floor(1.583)<br> <br> Result: 1<br> <br>2. floor(-10.328)<br> <br> Result: -11

10) log(Decimal value)

HeaderValue
Return TypeNumber
Syntaxlog(value)
DescriptionReturns the natural logarithm (base e) of a value.
Example1. log(10.504667)<br> <br> Result: 2.351819634603672<br> <br>2. log(1)<br> <br> Result:0

11) max(Decimal value1, Decimal value2)

HeaderValue
Return TypeNumber
Syntaxmax( value1, value2)
DescriptionReturns the greater of two values.
Example1. max(1, 2)<br> <br> Result: 2<br> <br>2. max(1000, 23.6)<br> <br> Result: 1000

12) min(Decimal value1, Decimal value2)

HeaderValue
Return TypeNumber
Syntaxmin( value1, value2)
DescriptionReturns the smaller of two values.
Example1. min(1, 2)<br> <br> Result: 1<br> <br>2. min(1000, 23.6)<br> <br> Result: 23.6

13) round(Decimal value, Number decimal place)

HeaderValue
Return TypeNumber
Syntaxround( value,decimal place)
DescriptionRounds a number to the specified decimal places.
Example1.  round(1.3456,3)<br> <br>Result: 1.346<br>2. round(10.456, 0)<br> <br>Result: 10

14) sin(Decimal value)

HeaderValue
Return TypeNumber
Syntaxsin(value)
DescriptionReturns the trigonometric sine of an angle.
Example1. sin(1.5707963267948966)<br> <br>Result: 1<br>2. sin(0)<br> <br>Result: 0

15) sqrt(Decimal value)

HeaderValue
Return TypeNumber
Syntaxsqrt(value)
DescriptionReturns the positive square root of a value.
Example1. sqrt(4)<br> <br>Result: 2<br>2. sqrt(100)<br> <br> Result: 10

16) tan(Decimal value)

HeaderValue
Return TypeNumber
Syntaxtan(value)
DescriptionReturns the arc tangent of the given value<br>Returned value range: -PI/2 through PI/2.
Example1.  tan(1.5707963267948966)<br> <br> Result: 16331239353195370<br> <br>2. tan(0)<br> <br> Result: 0

17) toDegrees(Decimal radians)

HeaderValue
Return TypeNumber
SyntaxtoDegrees(radians)
DescriptionConverts an angle in radians to the approximately equivalent angle in degrees.
Example1. toDegrees(1.5707963267948966)<br> <br>Result: 90<br>2. toDegrees(1)<br> <br> Result: 57.29577951308232

18) toRadians(Decimal degrees)

HeaderValue
Return TypeNumber
SyntaxtoRadians(degrees)
DescriptionConverts an angle in degrees to the approximate equivalent angle in radians.
Example1. toRadians(90)<br> <br> Result: 1.5707963267948966<br> <br>2. toRadians(0)<br> <br> Result: 0

19) randomNumberOfLength(Decimal value)

HeaderValue
Return TypeNumber
SyntaxrandomNumberOfLength(value)
DescriptionReturns random number of the specified length.
Example1. randomNumberOfLength(3)<br> <br> Result: 842<br> <br>2. randomNumberOfLength(4)<br> <br> Result: 1729

Conditional Functions

1\. if(conditional\_expression, expression\_if\_true , expression\_if\_false)

HeaderValue
Return Typestring/boolean/number
Syntaxif(conditional\_epression, expression\_if\_true , expression\_if\_false)
Description- conditional\_expression \- An expression that represents some logical value( i.e.TRUE or FALSE) or boolean value.<br> <br>- expression\_if\_true \-  executes conditions set for True if criteria matches<br> <br>- expression\_if\_false - executes condition set for False if criteria fails.<br> <br>- The expression\_if\_true, expression\_if\_false and return\_type should be of the same type.
Example1. if (2>1, "greater", "smaller")<br> <br>Result: greater

Date Functions

1\. addDays(date, number of days)

HeaderValue
Return TypeDate/Date-time
SyntaxaddDays(“date/date-time”, number of days)<br>Only ISO formatteddate/date-time placeholders are accepted. <br>date - ( yyyy-mm-dd )<br>date-time - ( ( yyyy-mm-ddThh:mm:ssZ ))
DescriptionAdds the specified number of days to the given date.<br>Negative days value will subtract the number of days from the given date.
Example1. addDays(“2019-12-31”,12)<br> <br>            Result: 2020-01-12<br>II.     addDays(“2019-12-31T00:45:34Z”,12)<br>Result: 2020-01-12T00:45:34Z

2\.  addMonths(date, months)

HeaderValue
Return TypeDate/Date-time
SyntaxaddMonths(date/date-time, number of months)<br>date - ( yyyy-mm-dd )<br>date-time - ( ( yyyy-mm-ddThh:mm:ssZ ))
DescriptionAdds the specified number of months to the given date.<br>Negative months value will subtract the number of months from the given date.
Example1. addMonths(“2019-12-31”,19)<br> <br>            Result: 2021-07-31<br>2. addMonths(“2019-12-31T00:45:34Z”,19)<br> <br>Result: 2021-07-31T00:45:34Z

3\.  addYears(date, years)

HeaderValue
Return TypeDate/Date-time
SyntaxaddYears(date/date-time, number of years)<br>date - ( yyyy-mm-dd )<br>date-time - ( ( yyyy-mm-ddThh:mm:ssZ ))
DescriptionAdds the specified number of years to the given date.<br>Negative years value will subtract the number of years from the given date.
Example1. addYears(“2019-12-31”,4)<br> <br>            Result: 2023-12-31<br>2. addYears(“2019-12-31T00:45:34Z”,-4)<br> <br>Result: 2015-12-31T00:45:34Z

4\.  date(year,month,day)

HeaderValue
Return TypeDate
Syntaxdate(year,month,day)
DescriptionReturns the value in date format (yyyy-mm-dd).
Example1. date(2019,12,31)<br> <br> Result: 2019-12-31

5\. dateTime(year,month,day,hour.min,sec,timezone)

HeaderValue
Return TypeDate-time
Syntaxdate(year,month,day,hour,min,sec,timezone)
DescriptionReturns the value in date-time format (yyyy-mm-ddThh:mm:ss+timezone).
Example1. date(2019,12,3,23,1,50,”Asia/Kolkata”)<br> <br> Result: 2019-12-31T23:01:50+05:30

6\. day(date/date-time)

HeaderValue
Return TypeNumber
Syntaxday(date/date-time)<br>date - ( yyyy-mm-dd )<br>date-time - ( ( yyyy-mm-ddThh:mm:ssZ )
DescriptionExtracts the day from the given date expression.
Example1. day(“ 2019-12-31”)<br> <br> Result: 31

7\. month(date/date-time)

HeaderValue
Return TypeNumber
Syntaxmonth(date/date-time)<br>date - ( yyyy-mm-dd )<br>date-time - ( yyyy-mm-ddThh:mm:ssZ )
DescriptionExtracts the month from the given date expression.
Example1. month(“2019-12-31T00:45:34Z”)<br> <br> Result: 12

8\. now(timezone)

HeaderValue
Return TypeDate-time
Syntaxnow(timezone)
DescriptionReturns the current time for the given timezone.
Example1. now(“Asia/Kolkata”)<br> <br> Result: 2019-08-06T00:45:34+05:30

9\. today(timezone)

HeaderValue
Return TypeDate-time
Syntaxtoday(timezone)
DescriptionReturns the current date for the given timezone.
Example1. today(“Asia/Kolkata”)<br> <br> Result: 2019-08-06

10\. weekday(date)

HeaderValue
Return TypeDate-time
Syntaxweekday(date)
DescriptionReturns the weekday number for the date given.<br>Sunday-1<br>Saturday-7
Example1. weekday(“2019-12-31”)<br> <br> Result: 3

11\. year(date)

HeaderValue
Return TypeNumber
Syntaxyear(date/date-time)<br>date -(yyyy-mm-dd)<br>date-time- ( yyyy-mm-ddThh:mm:ssZ )
DescriptionExtracts the year from the given date format.
Example1. year(“2019-12-31”)<br> <br> Result: 2019<br> <br>2. year(“2019-12-31T00:45:34Z”)<br> <br> Result: 2019

12\. dateTimeValue(date,timezone)

HeaderValue
Return TypeDate-time
SyntaxdateTimeValue(date,timezone)
DescriptionReturns the value in date-time format ( yyyy-mm-ddThh:mm:ssZ )
ExampleRefer to the following table, which provides an example on various scenarios, inputs, and behaviour.

_Note: These changes are applicable from August 2025._

ScenarioInput - dateTimeInput - timezonePrevious BehaviourNew Behaviour (from Aug 2025)
1\. Date input"2025-06-02""Asia/Kolkata"Interprets as 2025-06-02T00:00:00 in Asia/Kolkata → 2025-06-02T00:00:00+05:30Treats date as 2025-06-02T00:00:00Z → Converts to Asia/Kolkata → 2025-06-02T05:30:00+05:30
2\. DateTime input with Z (UTC)"2025-06-02T00:00:00Z""Asia/Kolkata"❌Throws error 1505 – invalid operandConverts UTC to zone → 2025-06-02T05:30:00+05:30
3\. DateTime input with Z (UTC)"2025-06-02T12:24:30Z""UTC"❌Throws error 1505 – invalid operandReturns input as-is → 2025-06-02T12:24:30Z
4\. DateTime input with offset"2025-06-02T00:00:00+05:30""Australia/Sydney"❌Throws error 1505 – invalid operandConvert from input offset → UTC → target zone → 2025-06-02T04:30:00+10:00
5\. DateTime input with offset"2025-06-02T12:00:00+00:00""UTC"❌Throws error 1505 – invalid operandSame time in UTC → 2025-06-02T12:00:00Z

13\. dateValue(datetime)

HeaderValue
Return Typedate
SyntaxdateValue(datetime)
DescriptionReturns the value in date format (yyyy-mm-dd).
Example1. dateValue(“1993-07-13T00:00:00+09:00”)<br> <br> Result: 1993-07-13

14\. addhours

HeaderValue
Return TypeDate/Date-time
SyntaxaddHours(date/date-time, hours)<br>date - ( yyyy-mm-dd )<br>date-time - ( ( yyyy-mm-ddThh:mm:ssZ))
DescriptionAdds the specified number of hours to the given date.<br>Negative days value will subtract the number of days from the given date.
Exampleaddhours(“2019-12-31”,28)<br>Result: 2020-01-01<br>addhours ("2019-12-31T00:45:34Z",12)<br>Result: "2019-12-31T12:45:34Z"

15\. diffInHours

HeaderValue
Return TypeNumber/Decimal
SyntaxdiffInHours( start\_date, end\_date )<br>date - ( yyyy-mm-dd )<br>date-time - ( ( yyyy-mm-ddThh:mm:ssZ))
DescriptionReturns difference in hours between the start date and end date.<br>If the end date occurs before the start date the result will be a negative number.
Example1. diffInHours(“1993-07-13”,”1993-07-15”)<br> <br> Result: 48<br> <br>2. diffInHours("1993-07-13T11:45:34Z","1993-07-15")<br> <br> Result: 36

16\. diffInDays

HeaderValue
Return TypeNumber/Decimal
SyntaxdiffInDays( start\_date, end\_date )<br>date - ( yyyy-mm-dd )<br>date-time - ( ( yyyy-mm-ddThh:mm:ssZ))
DescriptionReturns difference in days between the start date and end date.<br>If the end date occurs before the start date the result will be a negative number.
Example1. diffInDays(“1993-07-13”,”1993-07-15”)<br> <br> Result: 2<br> <br>2. diffInDays("1993-07-13T11:45:34Z","1993-07-15")<br> <br> Result: 1

17\. diffInWeeks

HeaderValue
Return TypeNumber/Decimal
SyntaxdiffInWeeks( start\_date, end\_date )<br>date - ( yyyy-mm-dd )<br>date-time - ( ( yyyy-mm-ddThh:mm:ssZ))
DescriptionReturns difference in weeks between the start date and end date.<br>If the end date occurs before the start date the result will be a negative number.
Example1. diffInWeeks("1993-07-13T11:45:34Z","1993-07-06T11:45:34Z")<br> <br> Result: -1

``` Note: We recommend verifying the syntax in the expression node to ensure smooth workflow automation execution. ```