Functions Reference
The following tables describe the functions that may be used to create calculated fields in Data Prep Studio.
Date Functions
Date functions operate on or with dates.
Function & Syntax 
Description 
Returns the number of whole intervals between the given start date and end date. 

Returns the week number of the calendar week in which the given date falls. This is similar to the Week function, but it does week numbering according to the current settings under Options/Time Intervals. 

Returns the date portion of a given date/time or today's date. 

Returns the given date value adjusted forward or backward by the given integral number of years, months, and days. 

Returns the number of day (131) from a date. 

Returns the day number (1366) from a date/time. 

Returns the number of days between the given start date and end date, based on a 360day year. If method is 0 (or omitted) then the calculation is based on the US (NASD) method, otherwise it is based on the European method. 

Returns the date of the first day of the interval in which the given date falls, where interval_type specifies the type of time interval. 

Returns the day number of the day within the fiscal year in which the given date falls. 

Returns the number (1 or 2) of the fiscal halfyear in which the given date falls. 

Returns the number (113) of the fiscal period in which the given date falls. 

Returns the number (14) of the fiscal quarter in which the given date falls. 

Returns the week number of the fiscal week in which the given date falls. 

Returns the year number of the fiscal year in which the given date falls. If at_start is 0 or not given, then the fiscal year is numbered for the calendar year in which it ends. If at_start is nonzero, then the fiscal year is numbered for the calendar year in which it starts. 

Returns the number (1 or 2) of the calendar halfyear in which the given date falls. 

Returns the hour (023) from a date/time. 

Returns the day number within the ISO8601 year on which the given date falls. 

Returns the ISO8601 week number of the week in which the given date falls. 

Returns the number of the day of the week for the given date, where 1=Monday, 2=Tuesday, …, 7=Sunday. 

Returns the year corresponding to the ISO8601 week in which the given date falls. For dates near the end of December or the start of January this may be different than the calendar year. 

Returns the date of the last day of the interval in which the given date falls, where interval_type specifies the type of time interval. 

This function returns the larger of expr1, expr2 and optionally expr3 and expr4. Accepts numeric, date or character input. 

This function returns the smaller of expr1, expr2 and optionally expr3 and expr4. Accepts numeric, date or character input. 

Returns the minute (059) from a date/time. 

Returns the number of month (112) from a date. 

Returns the current date and time. 

Returns
the quarter of the year within which a date falls: 

Returns the second (059) from a date/time. 

Returns the time portion of a date/time or the current time. 

Returns today’s date (i.e., the current system date). 

Returns the number of week (153) from a date. startday designates the day that begins each week. 

Returns the number of the weekday (17) of a date. startday designates the day that begins each week. 

Returns the number of year from a date. Valid range is 16012400. 

Returns the fractional number of years represented by the number of whole days between the given start date and end date, according to basis, which has the following meanings: 0 (or omitted)=US (NASD) 30/360; 1=actual/actual; 2=actual/360; 3=actual/365; 4=European 30/360. 
String Functions
String functions operate on or with character strings.
Function & Syntax 
Description 
Extracts a substring between a starting string and an optional ending string. 

Returns the numeric position of search string within the field specified in target string. If the search string is not found, a value of zero is returned. 

This function trims any sequence of consecutive spaces within a string to a single space, and also removes any leading or trailing spaces from it. 

Returns 1 (true) if character is alphabetic, otherwise returns 0 (false). 

Returns 1 (true) if string is either empty or contains all blanks, otherwise returns 0 (false). 

Returns 1 (true) if character is a lowercase alphabetic, otherwise returns 0 (false). 

Returns 1 (true) if character is an uppercase alphabetic, otherwise returns 0 (false). 

Returns n number of characters from the beginning of string. 

Returns the length of string as a number. 

Converts all uppercase letters in string to lowercase letters. 

Starts on the left and splits string into the specified number of parts (maxparts) using sep as the separator. sep may be a single character or a substring. n specifies which part to return. 

Removes leading spaces from string. 

This function returns the larger of expr1, expr2 and optionally expr3 and expr4. Accepts numeric, date or character input. 

This function returns the smaller of expr1, expr2 and optionally expr3 and expr4. Accepts numeric, date or character input. 

Reads string as a person’s name, splits it into five substrings  prefix, first name, middle initial or middle name, last name, and suffix  then returns the specified substring (n). 

Forces to uppercase the first letter of each word in string. 

Reads string as a postal code, splits it into 3 substrings  city, state, and postal code  then returns the specified substring (n). 

Scans the given string for matches to the given regular expression pattern. Returns the text of the Nth match found. If N is not given, this function returns the text of the first match found, if any. 

Scans the given string for a match to the given regular expression pattern. Returns 1 if a match was found, 0 otherwise. 

Scans the given string for matches to the given regular expression pattern. Each match found is replaced according to the substitutions in the replacement string, and the overall resultant string is returned. 

Splits the given string into pieces based on matches of the given regular expression pattern. Returns the requested piece, which is a 1based number indicating the desired piece, counting from the left. Returns the first piece if piece is not specified. 

Replaces a substring in a string with a new substring. 

Returns n number of characters from the end of string. 

Starts on the right and splits string into the specified number of parts (maxparts) using sep as the separator. sep may be a single character or a substring. n specifies which part to return. 

Trims trailing spaces from string. 

Returns a string consisting of a specified number of spaces. 

Strips the indicated characters (stripchars) from string. 

Returns a string by replacing n number of characters in string s, starting at position p, using replacement string c. 

Extracts a substring of a specified length and starting position from string. 

Splits a multiline string at the line breaks and returns the specified line. 

Trims leading and trailing spaces from string. 

Converts all lowercase letters in a character string to uppercase letters. 
Numeric Functions
Numeric functions operate on or with numbers.
Function & Syntax 
Description 
Returns the absolute value of a number. 

Rounds a number up (to the next multiple of number2, if specified). 

Returns e raised to a number. 

Rounds a number down (to the previous multiple of number2, if specified). 

Returns the distance between (lat1,long1) and (lat2,long2) where the latitudes and longitudes are specified in degrees. If use_metric is 0 or not given, the distance is returned in miles, otherwise the the distance is returned in kilometers. 

Returns the integer portion of a number. 

Returns the natural logarithm (base e) of a number. 

This function returns the larger of expr1, expr2 and optionally expr3 and expr4. Accepts numeric, date or character input. 

This function returns the smaller of expr1, expr2 and optionally expr3 and expr4. Accepts numeric, date or character input. 

Returns the remainder after dividing number1 by number2. 

Rounds a number to the nearest multiple of number2. 

Returns the value of Pi 

Rounds number to a specified number of places to the right (or left) of the decimal point. Note: Negative values of decimals round the integer portion of the number rather than the decimal portion. 

Returns the square root of number. 

Returns 0.0 if expression is null, otherwise returns the value of the expression. Applies only to numeric expressions. 
Conversion Functions
Conversion functions convert a value of one type to another type, such as a date to a string.
Function & Syntax 
Description 
Returns the numeric value of a character. 

Decodes a string from a Base64 format string. 

Encodes a string to a Base64 format string. 

Converts a time string to a number representing seconds since midnight. 

Returns the character value of a number. 

Converts a string to date format. date format is an optional parameter that indicates the date format, "m/d/y", "d/m/y" or "y/m/d". extraction format is an optional parameter that indicates the date/time extraction pattern. "D" extracts a date, "DT" extracts a date followed by a time, "T" extracts a time and "TD" extracts a time followed by a date. More than one extraction pattern may be combined to form a list of extraction patterns. For example: "D,DT" means extract a date OR a date followed by a time. 

Converts a date to a Julian date string of the given length. Default length is 5. 

Converts a number of degrees,minutes and seconds to decimal degrees. 

Converts an angle in degrees to an angle in radians 

Converts a date to character format. 

Converts a Julian date string to a date. 

Converts a number of kilometers to miles 

Converts a number of miles to kilometers. 

Converts an angle in radians to an angle in degrees 

Converts a number representing seconds since midnight to a time string. 

Converts a number to a string. length is the total length of the string to return, decimals specifies the decimal position to round, and fillchar is a character used to fill up to the value specified in length. 

Converts a string to a number. Note: The string must begin with a numeric character or a negation sign. If the string contains any nonnumeric characters (apart from a decimal delimiter character) this function will convert the numeric portion of the string up to the first nonnumeric character it encounters. 
Report Functions
Report functions return information relating to the source of a record.
Function & Syntax 
Description 
Returns detail record number. Each record is assigned a record number when the record is generated from a detail line in the report (e.g., Recno=1 always corresponds to the first detail line extracted from the report). Record numbers do not change when a filter is applied to the table or when the table is sorted, but do change if the detail template is modified in such a way as to yield more or fewer records). 

Returns the row number of a record. This function differs from the Recno function in that row numbers are reassigned each time you sort or filter the table while record numbers are not. 
Redaction Functions
Monarch Data Prep Studio provides the following functions that will allow you to replace, or mask out field values, so that only a representation of the field value is displayed, and not the actual value.
Function & Syntax 
Description 
Redacts the given text by striking out characters with a given overstrike character, optionally keeping any blanks. 

Redacts the given text by striking out characters with a given overstrike character, optionally keeping any blanks. 
Trigonometric Functions
Monarch Data Prep Studio provides the following special functions that allow you to carry out trigonometric calculations.
Function & Syntax 
Description 
Returns the arccosine, also known as inverse cosine, value (in radians) of a given number. 

Returns the arcsine, also known as inverse sine, value (in radians) of a given number. 

Returns the arctangent, also known as inverse tangent, value (in radians) of a given number. 

Returns the arctangent, also known as inverse tangent, value (in radians) of y/x 

Returns the cosine of an angle. 

Returns the cotangent of an angle. 

Returns the cosecant of an angle. 

Returns the distance between two points on a sphere given their longitudes and latitudes. This function uses the haversine formula to compute for the distance. The calculation assumes the earth's radius to be 3958.7613 miles / 6371.0088 kilometers. 

Returns the secant of an angle (specified in radians) 

Returns the sine of an angle. 

Returns the tangent of an angle. 
Special Functions
Monarch Data Prep Studio provides the following special functions that can be used to perform comparisons, check the status of fields, or generate random numbers (for use in auditing or other applications).
Function & Syntax 
Description 
Returns true value or false value from a conditional expression. If the expression is true, the true value is returned, otherwise the false value is returned. The return value may be a date, string or number. 

Returns 1 if field is empty, otherwise returns 0. Note: The field parameter must be the name of a field from the Table window. 

Returns 1 if expression is null, otherwise returns 0. 

Returns a record’s random number in the range 0 to 32767. 

Return’s a record’s random number in the range 0 to 4294967295 