Text Formula Functions

Text Functions

Note: All text formulas which use text strings are case-sensitive; "abc" is not the same as "ABC".

Function NameFunction with ArgumentsDescriptionExample with Result
leftleft(String, End Position)The first characters in a text string, based on the number of characters specifiedleft(Sample, 3) = Sam
rightright(String, End Position)The last characters in a text string, based on the number of characters specifiedright(Sample, 3) = ple
midmid(String, Start Position, Number of Characters)Extract a sub-string of a string, starting at the Start Position (count from zero from the left side) and ending at the Number of Characters to the right of it (including itself)mid(Sample, 2, 4) = amp
trimtrim({Name})Remove the white space from both left and right of a variabletrim( Smith ) = Smith
trimLefttrimLeft({Name})Remove whitespace left of a variabletrimLeft( Smith ) = "Smith "
trimRighttrimRight({Name})Remove whitespace right of a variabletrimRight( Smith ) = " Smith"
lengthlength(String)Get the number of characters in a text stringlength(Sample) = 6
replacereplace(String, Search Value, Replace Value)Replace a value found in a string with another valuereplace(ABCabc123, ABC, 123) = 123abc123
lowerlower(String)Convert a text string to lowercaselower(SaMpLe) = sample
upperupper(String)Convert a text string to uppercaseupper(SaMpLe) = SAMPLE
capitalizecapitalize(String)Capitalize the first letter of a stringcapitalize(sample) = Sample
randomrandom(Length)Output a random string containing the Length argument number of upper-case letters, lower-case letters, and numbersrandom(length(String)) = h0bFit
numberToWordsnumberToWords(String)Convert a number to its written formnumberToWords(110) = one hundred ten

Regex Functions

Note: Please note that regex falls outside the scope of our support. We are unable to provide assistance with setup or troubleshooting related to regex.

Additionally, since it involves code-based solutions, we cannot guarantee its functionality or full compatibility with Knack.

For resources to help with regex, learn more here.

Function NameFunction with ArgumentsDescriptionExample with Result
regexReplaceregexReplace(String, Regular Expression Search, Replace Value)Replace a regular expression value found in a string with another valueregexReplace(Sample, [A-Z], 9999) = 9999ample
extractRegexextractRegex(String, Regular Expression Search)Extract the first matching regular expression from a stringextractRegex(SAMPLE, [A-Z]) = S

Address Functions

Address field data used in the examples below: 123 Main St., Apt. 2, Amonate, VA 24601, United States

Function NameFunction with ArgumentsDescriptionExample with Result
getAddressStreetgetAddressStreet(ADDRESS)Extract the street from an address fieldgetAddressStreet({Address}) = 123 Main St.
getAddressStreet2getAddressStreet2(ADDRESS)Extract the street 2 from an address fieldgetAddressStreet2({Address}) = Apt. 2
getAddressCitygetAddressCity(ADDRESS)Extract the city from an address FieldgetAddressCity({Address}) = Amonate
getAddressStategetAddressState(ADDRESS)Extract the state from an address fieldgetAddressState({Address}) = VA
getAddressZipgetAddressZip(ADDRESS)Extract the zip code from an address fieldgetAddressZip({Address}) = 24601
getAddressCountrygetAddressCountry(ADDRESS)Extract the country from an address fieldgetAddressCountry({Address}) = United States

Name Functions

Person field data used in examples below: Dr. Jane Rose Doe

Function NameFunction with ArgumentsDescriptionExample with Result
getNameTitlegetNameTitle(NAME)Extract the title from a person fieldgetNameTitle({Name}) = Dr.
getNameFirstgetNameFirst(NAME)Extract the first name from a person fieldgetNameFirst({Name}) = Jane
getNameMiddlegetNameMiddle(NAME)Extract the middle name from a person fieldgetNameMiddle({Name}) = Rose
getNameLastgetNameLast(NAME)Extract the last name from a person fieldgetNameLast({Name}) = Doe

Link Functions

Sample link field data: URL: https://www.example.com, Label: Example!

Function NameFunction with ArgumentsDescriptionExample with Result
getLinkURLgetLinkURL(LINK)Extract the URL from a Link FieldgetLinkURL({Link}) = https://www.example.com
getLinkLabelgetLinkLabel(LINK)Extract the label from a Link FieldgetLinkLabel({Link}) = Example!

Date Functions

Note: For additional date functions, take a look at our equation formulas which you can use to get the day, week, month, quarter, or year from a date field.

Sample date field data: April 15, 2017

Function NameFunction with ArgumentsDescriptionExample with Result
getDateDayOfWeekNamegetDateDayOfWeekName(DATE)Get the day of the weekgetDateDayOfWeekName({Date}) = Friday
getDateMonthOfYearNamegetDateMonthOfYearName(DATE)Get the month of the yeargetDateMonthOfYearName({Date}) = April

Date Formatter

The date format function allows you to transform date fields into various outputs.

Function NameFunction with ArgumentsDescriptionExample with Result
formatDateformatDate(DATE, Output Format)Transforms the date into the defined output formatformatDate({Date}, YYYY-MM-DD) = 2018-06-13

Date Formatter Output Options

The available date output options are listed below:

Year, Month, and Day Tokens

InputExampleDescription
YYYY20144-digit year
YY142-digit year
Y-25Year with any number of digits and sign
Q1..4Quarter of year. Sets month to first month in quarter.
M MM1..12Month number
MMM MMMMJan..DecemberMonth name in locale set by moment.locale()
D DD1..31Day of month
Do1st..31stDay of month with ordinal
DDD DDDD1..365Day of year
X1410715640.579Unix timestamp
x1410715640579Unix ms timestamp

Week Year, Week, & Weekday Tokens

InputExampleDescription
gggg2014Locale 4-digit week year
gg14Locale 2-digit week year
w ww1..53Locale week of year
e0..6Locale day of week
ddd ddddMon...SundayDay name in locale set by moment.locale()
GGGG2014ISO 4-digit week year
GG14ISO 2-digit week year
W WW1..53ISO week of year
E1..7ISO day of week

Hour, Minute, Second, Millisecond, & Offset Tokens

InputExampleDescription
H HH0..23Hours (24 hour time)
h hh1..12Hours (12 hour time used with a A.)
k kk1..24Hours (24 hour time from 1 to 24)
a Aam pmPost or ante meridiem (Note the one character "a" "p" are also considered valid)
m mm0..59Minutes
s ss0..59Seconds
S SS SSS0..999Fractional seconds
Z ZZ+12:00Offset from UTC as +-HH:mm, +-HHmm, or Z

Note: Currently, end date/time values cannot be extracted with the date formatter function.