0% found this document useful (0 votes)
9 views

FunctionsReport

Uploaded by

jvoyarzun81
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

FunctionsReport

Uploaded by

jvoyarzun81
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Functions Sample - Built-in Functions in JasperReports Library

Date & Time - Category for date and time manipulation functions

Parameters
Name  Description Return Type
Name Description Type Required
DATE Creates a date object using the specified information java.util.Date Year The year of the new date java.lang.Integer Yes
on day, month and year.
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 java.lang.String Selected date The date to format java.util.Date Yes
format pattern.
Format pattern java.lang.String Yes

DATERANGE Allows to create a JasperReports DateRange instance net.sf.jasperreports.types.d Date range details The date range information java.lang.Object Yes
starting from either a String expression or a Date ate.DateRange
instance.
DATEVALUE Gives the corresponding numeric value (long java.lang.Long Date object The object representing the date java.lang.Object Yes
milliseconds) for a specified date object.
DAY Returns the day of a given date. Date object can be a java.lang.Integer Selected date The object representing the date java.lang.Object Yes
String, long value (milliseconds) or Date instance itself.

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. java.lang.Integer Selected date The object representing the date java.lang.Object Yes
Date object can be a String, long value (milliseconds)
or Date instance itself.
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. java.lang.Integer Selected date The object representing the date java.lang.Object Yes
Date object can be a String, long value (milliseconds)
or Date instance itself.
MONTH Returns the month of a given date. Date object can be java.lang.Integer Selected date The object representing the date java.lang.Object Yes
a String, long value (milliseconds) or Date instance
itself.
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 java.lang.Integer Start date The initial date java.lang.Object Yes
dates (inclusive). Saturday and Sunday are not
considered working days. 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 java.lang.Integer Selected date The object representing the date java.lang.Object Yes
date. Date object can be a String, long value
(milliseconds) or Date instance itself.
TIME Returns a text string representing a time value (hours, java.lang.String Hours The hours for the new time value java.lang.Integer Yes
seconds and minutes). If no specific pattern is provided
a default formatter is used. 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 java.lang.Integer Selected date The object representing the date java.lang.Object Yes
object can be a String, long value (milliseconds) or
Date instance itself. Sunday is first day 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 java.util.Date Selected date The object representing the date java.lang.Object Yes
and Sundays are not considered working days.
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 java.lang.Integer Selected date The object representing the date java.lang.Object Yes
String, long value (milliseconds) or Date instance itself.

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

Parameters
Name  Description Return Type
Name Description Type Required
AND Returns true if all arguments are considered true, false java.lang.Boolean Argument [Ljava.lang.Boolean Yes
otherwise. ;
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 java.lang.Object Test condition An expression returning a boolean value java.lang.Boolean Yes
condition.
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 java.lang.Boolean Argument A boolean expression or value java.lang.Boolean Yes
expression.
OR Returns true if any of the arguments is considered true, java.lang.Boolean Argument [Ljava.lang.Boolean Yes
false otherwise. ;
TRUE Returns the logical value TRUE. java.lang.Boolean

Numeric / Mathematical - Category for mathematical operations functions

Parameters
Name  Description Return Type
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 java.lang.Double Number Value java.lang.Number Yes
to the argument and is equal to a mathematical
integer.
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 java.lang.Double Number Value java.lang.Number Yes
the argument and is equal to a mathematical integer.

ISEVEN Checks if a number is even. If a non-integer number is java.lang.Boolean Number The number to check java.lang.Number Yes
specified, any digits after the decimal point are
ignored.
ISODD Checks if a number is odd. If a non-integer number is java.lang.Boolean Number The number to check java.lang.Number Yes
specified, any digits after the decimal point are
ignored.
MAX Returns the maximum of a list of numeric values. java.lang.Number Number [Ljava.lang.Number Yes
;
MIN Returns the minimum of a list of numeric values. java.lang.Number Number [Ljava.lang.Number Yes
;
PRODUCT Returns the product of a list of numbers. java.lang.Number Number [Ljava.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 java.lang.Integer Bottom range Integer number for the bottom range java.lang.Integer Yes
and top range (both inclusive).
Top range Integer number for the top range java.lang.Integer 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 java.lang.Number Positive number Argument java.lang.Number Yes
number must be positive.
SUM Returns the sum of a list of numbers. java.lang.Number Number [Ljava.lang.Number Yes
;

Text - Category for text/string manipulation functions

Parameters
Name  Description Return Type
Name Description Type Required
BASE Returns a text representation of a number, in a java.lang.String Number The positive integer number to convert java.lang.Integer Yes
specified base radix.
Radix The base radix, an integer between 2 and 36 java.lang.Integer Yes

Minimum length java.lang.Integer No

CHAR Returns a single text character, given a character java.lang.String Char code The character code, in the range 1-255 java.lang.Integer Yes
code.
CLEAN Returns a new text string without non-printable java.lang.String Text The text to be cleaned java.lang.String Yes
characters.
CODE Returns the numeric code (0-255) for the first character java.lang.Integer Text java.lang.String Yes
in a string.
CONCATENATE Combines a list of strings into a single one. java.lang.String Text Argument [Ljava.lang.String; Yes

DOUBLE_VALUE Returns a Double number representing the given text java.lang.Double Number (as text) The input text string representing a number java.lang.String Yes
string.
EXACT Returns TRUE if the two text specified are exactly the java.lang.Boolean Text 1 The first text to compare java.lang.String Yes
same (case sensitive compare).
Text 2 The second text to compare java.lang.String Yes

FIND Returns the character position of a string inside java.lang.Integer Find text The text to look into java.lang.String Yes
another text. If the text is not found then -1 is returned.
Text to search The text string to search java.lang.String Yes

Start position java.lang.Integer No

FIXED Returns the text representing number with the java.lang.String Number The number to print out java.lang.Number Yes
specified decimal places.
Decimals The number of decimal places java.lang.Integer Yes

Omit separators java.lang.Boolean No

FLOAT_VALUE Returns a Float number representing the given text java.lang.Float Number (as text) The input text string representing a number java.lang.String Yes
string.
INTEGER_VALUE Returns an Integer number representing the given text java.lang.Integer Number (as text) The input text string representing a number java.lang.String Yes
string.
LEFT Returns the specified number of characters (1 by java.lang.String Text The input text java.lang.String Yes
default) from the left side of the input text.
Characters num 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 java.lang.Long Number (as text) The input text string representing a number java.lang.String Yes
string.
LOWER Performs the lower case conversion of the specified java.lang.String Text The input text string java.lang.String Yes
text string.
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 java.lang.String Text The input text java.lang.String Yes
remaining parts of words are in lowercase.
REPLACE Replaces parts of a text string with a different one. java.lang.String Original Text The input text to modify java.lang.String Yes
Starting from a specified position, removes a certain
number of characters and then insert the new text. Start position 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 java.lang.String Original Text The input text to replicate java.lang.String Yes
times.
Number of copies The needed number of copies java.lang.Integer Yes

RIGHT Returns the specified number of characters (1 by java.lang.String Text The input text java.lang.String Yes
default) from the right side of the input text.
Characters num 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. java.lang.Integer Find Text The text to find java.lang.String Yes
Search is not case-sensitive.
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 java.lang.String Original Text The text to be modified java.lang.String Yes
no occurrence is specified all occurrences are
replaced. 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 java.lang.String Generic value The object value to be tested java.lang.Object Yes
an empty string is returned.
TEXT Converts a number into a text string according to a java.lang.String Number The number to be formatted java.lang.Number Yes
specified format.
Format The format pattern java.lang.String Yes

TRIM Clear a string,removing leading and trailing java.lang.String Text The text string to be trimmed java.lang.String Yes
whitespaces.
UPPER Performs the upper case conversion of the specified java.lang.String Text The input text string java.lang.String Yes
text string.

Built-in Functions Examples

Numeric / Mathematical Functions 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() 155,73

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

Date & Time Functions Expression Result

Current date DATEFORMAT(NOW(), "EEEE, MMM d, yyyy") luni, Oct 3, 2016

Current year YEAR(TODAY()) 2016

Four months later DATEFORMAT(EDATE(TODAY(), 4), "MM/dd/yyyy") 02/03/2017

Five years ago DATEFORMAT(EDATE(TODAY(), -60), "MMMM d, yyyy") octombrie 3, 2011

Current week number WEEKNUM(TODAY()) 40

Next working day DATEFORMAT(WORKDAY(TODAY(),1), "EEE, MMM dd") Ma, Oct 04

Years since 2000 YEARS(DATE(2000, 1, 1), NOW()) 16

Current time DATEFORMAT(TODAY(), "hh:mm:ss a") 08:09:07 PM

Text Functions 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 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

Page 1 of 1

You might also like