JasperReports logo version 7.0.0 Home - Samples - Configuration - Functions - FAQ - API (Javadoc)

JasperReports - Function Reference


Built-in Functions in JasperReports Library
Date & Time - Category for date and time manipulation functions
Name Description Return Type Parameters
Name Description Type Required
DATE Creates a date object using the specified information on day, month and year. java.util.Date Year The year of the new date java.lang.Integer Yes
Month The month of the new date java.lang.Integer Yes
Day of month The day of the new date java.lang.Integer Yes
DATEFORMAT Format the specified date object using the chosen format pattern. java.lang.String Selected date The date to format java.util.Date Yes
Format pattern Format pattern to apply when printing the date java.lang.String Yes
DATERANGE Allows to create a JasperReports DateRange instance starting from either a String expression or a Date instance. net.sf.jasperreports.types.date.DateRange Date range details The date range information java.lang.Object Yes
DATEVALUE Gives the corresponding numeric value (long milliseconds) for a specified date object. java.lang.Long Date object The object representing the date java.lang.Object Yes
DAY Returns the day of a given date. Date object can be a String, long value (milliseconds) or Date instance itself. java.lang.Integer Selected date The object representing the date java.lang.Object Yes
DAYS Returns the number of days between two dates. java.lang.Integer Start date The initial date java.lang.Object Yes
End date The end date java.lang.Object Yes
DAYSINMONTH Returns the number of days in a month. java.lang.Integer Selected date The date to check java.lang.Object Yes
DAYSINYEAR Returns the number of days in a year. java.lang.Integer Selected date The date to check java.lang.Object Yes
EDATE Returns a date a number of months away. java.util.Date Selected date The object representing the date java.lang.Object Yes
Months The number of months after the given date java.lang.Integer Yes
HOUR Returns the hour (0-23) of the day for a given date. Date object can be a String, long value (milliseconds) or Date instance itself. java.lang.Integer Selected date The object representing the date java.lang.Object Yes
ISLEAPYEAR Checks if the given date occurs in a leap year. java.lang.Boolean Selected date The date to check java.lang.Object Yes
MINUTE Returns the minute (0-59) of the hour for a given date. Date object can be a String, long value (milliseconds) or Date instance itself. java.lang.Integer Selected date The object representing the date java.lang.Object Yes
MONTH Returns the month of a given date. Date object can be a String, long value (milliseconds) or Date instance itself. java.lang.Integer Selected date The object representing the date java.lang.Object Yes
MONTHS Returns the number of months between two dates. java.lang.Integer Start date The initial date java.lang.Object Yes
End date The end date java.lang.Object Yes
NETWORKDAYS Returns the number of working days between two dates (inclusive). Saturday and Sunday are not considered working days. java.lang.Integer Start date The initial date java.lang.Object Yes
End date The end date java.lang.Object Yes
NOW Returns the current instant as date object java.util.Date
SECOND Returns the second (0-59) of the minute for a given date. Date object can be a String, long value (milliseconds) or Date instance itself. java.lang.Integer Selected date The object representing the date java.lang.Object Yes
TIME Returns a text string representing a time value (hours, seconds and minutes). If no specific pattern is provided a default formatter is used. java.lang.String Hours The hours for the new time value java.lang.Integer Yes
Minutes The minutes for the new time value java.lang.Integer Yes
Seconds The seconds for the new time value java.lang.Integer Yes
Format pattern The pattern to format the time value java.lang.String No
TODAY Returns the current date as date object java.util.Date
WEEKDAY Returns the day of the week for a given date. Date object can be a String, long value (milliseconds) or Date instance itself. java.lang.Integer Selected date The object representing the date java.lang.Object Yes
Sunday is first day Boolean flag to decide if Sunday should be considered as first day. Default is not java.lang.Boolean No
WEEKNUM Returns the week number of a given date. java.lang.Integer Selected date The date to check java.lang.Object Yes
WEEKS Returns the number of weeks between two dates. java.lang.Integer Start date The initial date java.lang.Object Yes
End date The end date java.lang.Object Yes
WEEKSINYEAR Returns the number of weeks in a year. java.lang.Integer Selected date The date to check java.lang.Object Yes
WORKDAY Returns a date a number of workdays away. Saturday and Sundays are not considered working days. java.util.Date Selected date The object representing the date java.lang.Object Yes
Working days The number of days after the given date java.lang.Integer Yes
YEAR Returns the year of a given date. Date object can be a String, long value (milliseconds) or Date instance itself. java.lang.Integer Selected date The object representing the date java.lang.Object Yes
YEARS Returns the number of years between two dates. java.lang.Integer Start date The initial date java.lang.Object Yes
End date The end date java.lang.Object Yes
Logical - Category for logical operations functions
Name Description Return Type Parameters
Name Description Type Required
AND Returns true if all arguments are considered true, false otherwise. java.lang.Boolean Argument A boolean expression or value java.lang.Boolean[] Yes
EQUALS Checks if the two specified objects are equal. java.lang.Boolean Object 1 The first element to be compared java.lang.Object Yes
Object 2 The second element to be compared java.lang.Object Yes
FALSE Returns the logical value FALSE. java.lang.Boolean
IF Returns one of two values, depending on a test condition. java.lang.Object Test condition An expression returning a boolean value java.lang.Boolean Yes
Value 1 (true) The value returned when the test is true java.lang.Object Yes
Value 2 (false) The value returned when the test is false java.lang.Object Yes
NOT Returns the negation of the specified boolean expression. java.lang.Boolean Argument A boolean expression or value java.lang.Boolean Yes
OR Returns true if any of the arguments is considered true, false otherwise. java.lang.Boolean Argument A boolean expression or value java.lang.Boolean[] Yes
TRUE Returns the logical value TRUE. java.lang.Boolean
Numeric / Mathematical - Category for mathematical operations functions
Name Description Return Type Parameters
Name Description Type Required
ABS Returns the absolute value of a number. java.lang.Number Number The number to check java.lang.Number Yes
CEIL Returns the smallest value that is greater than or equal to the argument and is equal to a mathematical integer. java.lang.Double Number Value java.lang.Number Yes
FACT Returns the factorial of a number. java.lang.Long Integer number The argument java.lang.Integer Yes
FLOOR Returns the largest value that is less than or equal to the argument and is equal to a mathematical integer. java.lang.Double Number Value java.lang.Number Yes
ISEVEN Checks if a number is even. If a non-integer number is specified, any digits after the decimal point are ignored. java.lang.Boolean Number The number to check java.lang.Number Yes
ISODD Checks if a number is odd. If a non-integer number is specified, any digits after the decimal point are ignored. java.lang.Boolean Number The number to check java.lang.Number Yes
MAX Returns the maximum of a list of numeric values. java.lang.Number Number Number to compare java.lang.Number[] Yes
MIN Returns the minimum of a list of numeric values. java.lang.Number Number Number to compare java.lang.Number[] Yes
PRODUCT Returns the product of a list of numbers. java.lang.Number Number Argument java.lang.Number[] Yes
RAND Returns a random number between 0.0 and 1.0. java.lang.Double
RANDBETWEEN Returns an Integer random number between bottom and top range (both inclusive). java.lang.Integer Bottom range Integer number for the bottom range java.lang.Integer Yes
Top range Integer number for the top range java.lang.Integer Yes
ROUND_CEILING Returns a BigDecimal number rounded towards positive infinity. For positive values behaves as the ROUND_UP function, for negative values behaves as the ROUND_DOWN function. java.math.BigDecimal Number The number to be rounded java.lang.Number Yes
Scale The rounding scale: the number of digits after the decimal point int Yes
ROUND_DOWN Returns a BigDecimal number rounded towards zero. It never increments the digit prior to a discarded fraction java.math.BigDecimal Number The number to be rounded java.lang.Number Yes
Scale The rounding scale: the number of digits after the decimal point int Yes
ROUND_FLOOR Returns a BigDecimal number rounded towards negative infinity. For positive values behaves as the ROUND_DOWN function, for negative values behaves as the ROUND_UP function. java.math.BigDecimal Number The number to be rounded java.lang.Number Yes
Scale The rounding scale: the number of digits after the decimal point int Yes
ROUND_HALF_DOWN Returns a BigDecimal number rounded towards its nearest neighbor. If both neighbors are equidistant, the number is rounded down. Behaves as the ROUND_UP function if the discarded fraction is > 0.5; otherwise, behaves as the ROUND_DOWN function. java.math.BigDecimal Number The number to be rounded java.lang.Number Yes
Scale The rounding scale: the number of digits after the decimal point int Yes
ROUND_HALF_EVEN Returns a BigDecimal number rounded towards its nearest neighbor. If both neighbors are equidistant, the number is rounded towards the even neighbor. Behaves as the ROUND_HALF_UP function if the digit to the left of the discarded fraction is odd; otherwise, behaves as the ROUND_HALF_DOWN function. This rounding mode statistically minimizes cumulative error when it is repeatedly applied over a sequence of calculations. java.math.BigDecimal Number The number to be rounded java.lang.Number Yes
Scale The rounding scale: the number of digits after the decimal point int Yes
ROUND_HALF_UP Returns a BigDecimal number rounded towards its nearest neighbor. If both neighbors are equidistant, the number is rounded up. Behaves as the ROUND_UP function if the discarded fraction is ≥ 0.5; otherwise, behaves as the ROUND_DOWN function. java.math.BigDecimal Number The number to be rounded java.lang.Number Yes
Scale The rounding scale: the number of digits after the decimal point int Yes
ROUND_UP Returns a BigDecimal number rounded away from zero. It always increments the digit prior to a non-zero discarded fraction. java.math.BigDecimal Number The number to be rounded java.lang.Number Yes
Scale The rounding scale: the number of digits after the decimal point int Yes
SIGN Returns the sign of a number. java.lang.Integer Number The number to check java.lang.Number Yes
SQRT Returns the positive square root of a number. The number must be positive. java.lang.Number Positive number Argument java.lang.Number Yes
SUM Returns the sum of a list of numbers. java.lang.Number Number Addendum java.lang.Number[] Yes
Report - Report utility functions
Name Description Return Type Parameters
Name Description Type Required
ORIGINAL_DATA_SOURCE Returns the original data source, even when there are sort fields. net.sf.jasperreports.engine.JRDataSource
RESOURCE_DATA Loads a repository resource as a byte array byte[] Resource location The repository location of the resource java.lang.String Yes
SUB_DATA_SOURCE Creates a sub data source from the current JSON or XML data source net.sf.jasperreports.engine.JRDataSource
SUB_DATA_SOURCE Creates a sub data source from the current JSON or XML data source net.sf.jasperreports.engine.JRDataSource Select expression The expression used to select data for the sub data source java.lang.String No
Text - Category for text/string manipulation functions
Name Description Return Type Parameters
Name Description Type Required
BASE Returns a text representation of a number, in a specified base radix. java.lang.String Number The positive integer number to convert java.lang.Integer Yes
Radix The base radix, an integer between 2 and 36 java.lang.Integer Yes
Minimum length Specifies the minimum number of characters returned; zeroes are added on the left if necessary java.lang.Integer No
CHAR Returns a single text character, given a character code. java.lang.String Char code The character code, in the range 1-255 java.lang.Integer Yes
CLEAN Returns a new text string without non-printable characters. java.lang.String Text The text to be cleaned java.lang.String Yes
CODE Returns the numeric code (0-255) for the first character in a string. java.lang.Integer Text The string containing the character to convert java.lang.String Yes
CONCATENATE Combines a list of strings into a single one. java.lang.String Text Argument java.lang.String[] Yes
DOUBLE_VALUE Returns a Double number representing the given text string. java.lang.Double Number (as text) The input text string representing a number java.lang.String Yes
EXACT Returns TRUE if the two text specified are exactly the same (case sensitive compare). java.lang.Boolean Text 1 The first text to compare java.lang.String Yes
Text 2 The second text to compare java.lang.String Yes
FIND Returns the character position of a string inside another text. If the text is not found then -1 is returned. java.lang.Integer Find text The text to look into java.lang.String Yes
Text to search The text string to search java.lang.String Yes
Start position The position from which the search should start java.lang.Integer No
FIXED Returns the text representing number with the specified decimal places. java.lang.String Number The number to print out java.lang.Number Yes
Decimals The number of decimal places java.lang.Integer Yes
Omit separators The flag to specify if the thousands separators should be included or not java.lang.Boolean No
FLOAT_VALUE Returns a Float number representing the given text string. java.lang.Float Number (as text) The input text string representing a number java.lang.String Yes
INTEGER_VALUE Returns an Integer number representing the given text string. java.lang.Integer Number (as text) The input text string representing a number java.lang.String Yes
LEFT Returns the specified number of characters (1 by default) from the left side of the input text. java.lang.String Text The input text java.lang.String Yes
Characters num The number of characters. Default (not specified) is 1 java.lang.Integer No
LEN Returns the length of the specified text string. java.lang.Integer Text The input text string java.lang.String Yes
LONG_VALUE Returns a Long number representing the given text string. java.lang.Long Number (as text) The input text string representing a number java.lang.String Yes
LOWER Performs the lower case conversion of the specified text string. java.lang.String Text The input text string java.lang.String Yes
LTRIM Clear a string, removing leading whitespaces. java.lang.String Text The text string to be trimmed java.lang.String Yes
MID Returns the text from the middle of a text string. java.lang.String Text The input text java.lang.String Yes
Start The initial position to extract the text java.lang.Integer Yes
Characters num The number of characters java.lang.Integer No
PROPER Capitalizes each words of the specified text. The remaining parts of words are in lowercase. java.lang.String Text The input text java.lang.String Yes
REPLACE Replaces parts of a text string with a different one. Starting from a specified position, removes a certain number of characters and then insert the new text. java.lang.String Original Text The input text to modify java.lang.String Yes
Start position The number of characters. Default (not specified) is 1 java.lang.Integer Yes
Characters num The number of characters to remove java.lang.Integer Yes
New Text The text that will replace the old one java.lang.String Yes
REPT Replicates an input text string for a specified number of times. java.lang.String Original Text The input text to replicate java.lang.String Yes
Number of copies The needed number of copies java.lang.Integer Yes
RIGHT Returns the specified number of characters (1 by default) from the right side of the input text. java.lang.String Text The input text java.lang.String Yes
Characters num The number of characters. Default (not specified) is 1 java.lang.Integer No
RTRIM Clear a string, removing trailing whitespaces. java.lang.String Text The text string to be trimmed java.lang.String Yes
SEARCH Returns the position of a string of text in another string. Search is not case-sensitive. java.lang.Integer Find Text The text to find java.lang.String Yes
Text to search The text to look into java.lang.String Yes
Start position The initial position java.lang.Integer No
SUBSTITUTE Substitutes new text for old text in a text string. When no occurrence is specified all occurrences are replaced. java.lang.String Original Text The text to be modified java.lang.String Yes
Old Text The old text to be replaced java.lang.String Yes
New Text The new text that will replace the old one java.lang.String Yes
Occurrence The occurrence of old text to be replaced java.lang.Integer No
T Returns the text string if the value is a string, otherwise an empty string is returned. java.lang.String Generic value The object value to be tested java.lang.Object Yes
TEXT Converts a number into a text string according to a specified format. java.lang.String Number The number to be formatted java.lang.Number Yes
Format The format pattern java.lang.String Yes
TRIM Clear a string,removing leading and trailing whitespaces. java.lang.String Text The text string to be trimmed java.lang.String Yes
UPPER Performs the upper case conversion of the specified text string. java.lang.String Text The input text string java.lang.String Yes
Built-in Functions Examples
Numeric / Mathematical Functions
Description Expression Result
| -245 | is even ISEVEN(ABS(-245)) false
14.4 * 22.56 * 10 * 34 PRODUCT(14.4, 22.56, 10, 34) 110,453.76
Random number between 0 and 1000 1000 * RAND() 26.683
Factorial of 5 FACT(5) 120
SQRT(6.25) SQRT(6.25) 2.50
Max value in [4,6,2,3,9,4,1,7,3,8] MAX(4, 6, 2, 3, 9, 4, 1, 7, 3, 8) 9
123.4567 rounded up to 2 digits after the decimal ROUND_UP(123.4567, 2) 123.46
Date & Time Functions
Description Expression Result
Current date DATEFORMAT(NOW(), "EEEE, MMM d, yyyy") Monday, Sep 11, 2023
Current year YEAR(TODAY()) 2023
Four months later DATEFORMAT(EDATE(TODAY(), 4), "MM/dd/yyyy") 01/11/2024
Five years ago DATEFORMAT(EDATE(TODAY(), -60), "MMMM d, yyyy") September 11, 2018
Current week number WEEKNUM(TODAY()) 37
Next working day DATEFORMAT(WORKDAY(TODAY(),1), "EEE, MMM dd") Tue, Sep 12
Years since 2000 YEARS(DATE(2000, 1, 1), NOW()) 23
Current time DATEFORMAT(TODAY(), "hh:mm:ss a") 12:30:30 AM
Text Functions
Description Expression Result
Concatenate "Hello", " ", "World" CONCATENATE("Hello", " ", "World") Hello World
Case sensitive search for "ll' in "Hello" "Found on position " + (FIND("Hello", "ll") + 1) Found on position 3
Case insensitive search for "LL" in "all" "Found on position " + (SEARCH("LL", "all") + 1) Found on position 2
Lower case for "Hello WORLD" LOWER("Hello WORLD") hello world
Capitalize each word PROPER("Capitalize each word") Capitalize Each Word
Replicates "Hello " three times REPT("Hello ", 3) Hello Hello Hello
Substitute "o" by "0" in "Hello World" SUBSTITUTE("Hello World", "o", "0") Hell0 W0rld
Extract "orl" from "Hello World" MID("Hello World", 8, 3) orl
Logical Functions
Description Expression Result
This is true. TRUE() true
This is false. FALSE() false
3 < 5 AND 3 > 7 AND(3 < 5, 3 > 7) false
3 < 5 OR 3 > 7 OR(3 < 5, 3 > 7) true
Current month is before July IF(MONTH(TODAY()) < 7, "YES", "NO") NO



© 2001- Cloud Software Group, Inc. www.jaspersoft.com