Gravity Forms Advanced Calculations
Perform advanced calculations with mathematical functions, conditionals, and a powerful formula editor.
What does it do?
Advanced Calculations completely revamps calculations in Gravity Forms. Not only does it empower you with advanced mathematical functions and conditionals, it improves the formula editing experience with a powerful new editor, complete with syntax highlighting, autocompletion, shorthand field references, and so much more!
With Advanced Calculations you can create:
- Mortgage calculators with the Future Value function
- Advanced calculated products with conditional statements
- Loan calculators based on amount, interest and length
- Investment/Retirement calculators
- BMI calculators with selectable measurement units
- Cost estimators with conditional variables
- Donation tax break calculators with variable donation frequency
- Land value calculators with rounded land area
- And many more!
Features
- Heaps of mathematical functions.
Spreadsheet style math directly in your form, including date and time calculations. - Conditional statements.
Specify multiple formulas in the same field; use the right one based on your conditions with support for numbers and strings. - Formula shorthand.
Simplify your formulas with our field reference shorthand. No more cumbersome merge tags! - Syntax highlighting.
Clarify your complex formulas and spot issues quickly with automatic syntax highlighting. - Secure, tamperproof calculations.
All calculations are recalculated on submission for accuracy and security. - Seamless integration.
Automatically enhances all calculation-enabled fields like Number and Calculated Product fields. - Automatic updates.
Get updates and the latest features right in your dashboard. - Legendary support.
We’re here to help! And we mean it.
Documentation
How do I enable this functionality?
After installing and activating Gravity Forms Advanced Calculations,
|
Add a Number field to your form. |
|
Check Enable Calculation. |
|
Insert advanced calculations into form. Use the Formula Cheatsheet for a primer on calculations. |
Feature Details
Merge Tag Shorthand
The true power of calculations with Gravity Forms comes from being able to reference other fields to create calculations from what users have entered. Gravity Forms uses merge tags to reference fields. Merge tags are referenced using the field ID, with or without the descriptor, such as {Field A:1} or {:1}.
Gravity Forms Advanced Calculations adds shorthand for fields to clean up your calculations and make it easier to keep track of everything. The shorthand for the same field shown above is written as F1.
Shorthand offers more readable calculations, especially for complicated functions.
Conditional Statements
Advanced Calculations supports conditional statements such as if/else and if/elseif/else. Use these statements to evaluate calculations based on field values.
Usage Examples
if/else
if( F1 > 1.25 && F1 < 5.5 ):
F1 * 50
else:
0
endif;if/elseif/else
if( F1 < 5.5 ):
F1 * 50
elseif( F1 >= 10 ):
F1 * 25
else:
0
endif;You may use as many elseif statements as needed. You are not limited to one.
Supported Operators
The following comparison operators are supported:
==Equal to!=Not equal to>Greater than<Less than>=Greater than or equal to<=Less than or equal to
Comparing String Values
Comparison values can be either a number or a string (e.g. 123 or hello world).
A few things to note when comparing strings:
- Comparisons are case-sensitive.
hello worldwon’t matchHello World. - Comparisons are not sensitive to whitespace at the beginning and end of strings. Strings are trimmed by Gravity Forms before comparison, so a condition like this would still match a value of
hello(no whitespace).if ( F1 == ' hello ' ): - Comparisons can be made with any any single-value text-based field type, including choice-based fields like Drop Down and Radio Button fields.
Multiple Expressions
Conditional statements support multiple expressions within a single condition via the the && (and) or the || (or) operators.
To require both expressions to be true for the condition to match, you would use the && operator. In this example, the condition will only be true if Field #1 is greater than 5 and less than 10.
if ( F1 > 5 && F1 < 10 ):If you would like your condition to match if any of the conditions are true, you would use the || operator. In this example, the condition will return true if Field #1 is greater than 5 or if Field #2 is greater than 5.
if ( F1 > 5 || F2 > 5 ):While these examples are simple, this functionality is quite robust and can handle conditions that contain expressions with both && and || operators.
Worth noting that string-based conditions can be combined with number-based conditions.
if ( F1 == 'Package A' && F2 > 100 ):You can break complex conditionals onto multiple lines for readability.
Condition: Field Has Value
You can easily check if a field has a value like so:
if ( F1 ):Condition: Field Is Empty
You can check if a field is empty (has no value) like so:
if ( F1 == '' ):Condition: Field Values Match
You can check if the value of two different fields match like so:
if ( F1 == F2 ):This works with both numeric and string values.
Syntax Highlighting
Advanced Calculations adds syntax highlighting and autocompletion to the calculation text area. Syntax highlighting drastically improves the readability of calculations, especially complicated ones that use conditional statements and functions.
Autocompletion aids you when inputting a function or conditional statement. When you start typing any supported function, the editor will suggest a completion. Click the suggested function (or hit return) to insert the full function with placeholder values.

The editor also automatically closes parentheses and merge tag braces. Say goodbye to invalid formulas because of an errant parenthesis!
Tooltips
When hovering over shorthand field variables and merge tag field variables with no descriptor in the formula editor, you will see a tooltip displaying the field’s label.
Function Support
Advanced Calculations adds support for a variety of mathematical functions — date arithmetic for calculating working days between dates, time differences, statistics, trigonometry, financial projections, and more. These functions can also be combined and nested.
Available functions:
- Rounding & Precision
- Date-Based
- Time-Based
- Aggregation & Statistics
- Logarithms & Exponents
- Financial
- Trigonometry
- Constants
Arithmetic
| Operator | Description | Source |
+ | Add | Gravity Forms |
- | Subtract | Gravity Forms |
* | Multiply | Gravity Forms |
/ | Divide | Gravity Forms |
( ) | Parenthesis; enclose parts of the formula to be calculated first. | Gravity Forms |
% | Modulo; returns the remainder of a division. | Advanced Calculations |
^ | Exponentiation; raise a number to the power of an exponent. | Advanced Calculations |
Functions
Rounding & Precision
Absolute Value – abs
abs returns the absolute value of a number.
Show Details
Sample Usage
abs( -78 )abs( F1 )Syntax
abs( value )value– The value or field of which to return the absolute value.
Example
In the below example, the retuned value is 14.
abs( -14 )Ceiling – ceil
ceil rounds a number up to the next largest integer.
Show Details
Sample Usage
ceil( 25.4 )ceil( F1 )Syntax
ceil( value )value– The value to round up to the nearest integer.
Example
In the below example, the retuned value is 36.
ceil( 35.8 )Floor – floor
floor rounds a number down to the nearest integer.
Show Details
Sample Usage
floor( 75.763 )floor( F3 )Syntax
floor( value )value– The value to round down to the nearest integer.
Example
In the below example, the retuned value is 323.
floor( 323.78 )Round – round
round rounds a number to the nearest integer.
Show Details
Sample Usage
round( 12.7 )round( F2 )Syntax
round( value )value– The value to round to the nearest integer.
Example
In the below example, the retuned value is 9.
round( 8.68 )Date-Based
Age – age()
age() returns the number of years between a date and today, counting only completed years.
Show Details
Sample Usage
age( F1 )Syntax
age( date, unit='years' )date– The person’s birth date. Accepts field references and static dates.unit– Sets base unit for the function. Acceptsdays,weeks,months,years(default).
Example
In the below example, the returned value is 6 on May 16th, 2026.
age( '2019-05-18' )Difference Between Dates – datediff()
datediff() returns the number of dates between two dates with ample customization options.
Show Details
Sample Usage
datediff( F1, F2 )datediff( F1, F2, unit='months' )datediff( F1, today(), exclude=['holidays'] )datediff( '05-31-2026', F2, includeStart=false, includeEnd=true )Syntax
datediff( start, end, unit='days', includeStart=true, includeEnd=false, exclude=[], daysOfWeek='all' )start– The start date value. Accepts field references, static dates, or the current date. Static dates and dates from non-Date fields must be in ayyyy-mm-ddformat.end– The end date value. Accepts field references, static dates, or the current date. Static dates and dates from non-Date fields must be in ayyyy-mm-ddformat.- Optional parameters for customizing the main function.
| Parameter | What It Does | Accepted Values |
|---|---|---|
unit='value' | Sets base unit for the function | days (default), weeks, months, years |
includeStart=value | Sets whether to count the start date | true (default), false, or field reference |
includeEnd=value | Sets whether to count the end date | true, false (default), or field reference |
exclude='value'exclude=['value 1', 'value 2'] | Excludes specified dates from the function | Single values and arrays. Available Values: Learn more. |
daysOfWeek='value'daysOfWeek=['value 1', 'value 2'] | Restricts counting to specific days of the week. Unit Requirement: days | Single values and arrays. Available Values: all (default), weekdays, weekends, monday, tuesday, wednesday, thursday, friday, saturday, sunday |
abs='value' | Returns the absolute value | true (default), false, or field reference |
Example
In the below example, the returned value is 12 on May 14th 2026.
datediff( '05-01-2026', today(), exclude=['05-03-2026', 'us_federal_holidays' )Weekdays Between Dates – weekdays()
weekdays() returns the number of weekdays between two dates.
Show Details
Sample Usage
weekdays( F1, F2 )weekdays( F1, today() )Syntax
weekdays( start, end, includeStart=true, includeEnd=false, exclude=[] )start– The start date value. Accepts field references, static dates, or the current date. Static dates and dates from non-Date fields must be in ayyyy-mm-ddformat.end– The end date value. Accepts field references, static dates, or the current date. Static dates and dates from non-Date fields must be in ayyyy-mm-ddformat.- Optional parameters for customizing the main function.
| Parameter | What It Does | Accepted Values |
|---|---|---|
includeStart=value | Sets whether to count the start date | true (default), false, or field reference |
includeEnd=value | Sets whether to count the end date | true, false (default), or field reference |
exclude='value'exclude=['value 1', 'value 2'] | Excludes specified dates from the function | Single values and arrays. Available Values: Learn more. |
abs='value' | Returns the absolute value | true (default), false, or field reference |
Example
In the below example, the returned value is 21.
weekdays( '05-01-2026', '05-31-2026' )Weekend Days Between Dates – weekenddays()
weekenddays() returns the number of weekend days between two dates.
Show Details
Sample Usage
weekenddays( F1, F2 )weekenddays( F1, today() )Syntax
weekenddays( start, end, includeStart=true, includeEnd=false, exclude=[] )start– The start date value. Accepts field references, static dates, or the current date. Static dates and dates from non-Date fields must be in ayyyy-mm-ddformat.end– The end date value. Accepts field references, static dates, or the current date. Static dates and dates from non-Date fields must be in ayyyy-mm-ddformat.- Optional parameters for customizing the main function.
| Parameter | What It Does | Accepted Values |
|---|---|---|
includeStart=value | Sets whether to count the start date | true (default), false, or field reference |
includeEnd=value | Sets whether to count the end date | true, false (default), or field reference |
exclude='value'exclude=['value 1', 'value 2'] | Excludes specified dates from the function | Single values and arrays. Available Values: Learn more. |
abs='value' | Returns the absolute value | true (default), false, or field reference |
Example
In the below example, the returned value is 10.
weekenddays( '05-01-2026', '05-31-2026', includeEnd=true )Date Exclusions – exclude Parameter
The exclude parameter can exclude dates from date-based calculations.
Show Details
Syntax
exclude='value'exclude=['value 1', 'value 2']Supported Values
- Field references (Dates from non-Date fields must be in a
yyyy-mm-ddformat) - Static dates
- Dynamic dates
- Natural language dates (e.g., First Monday of May)
- PHP date groups
Field references aren’t supported in PHP date groups. To exclude dates coming from fields, add them directly in an array.
Example: exclude=['us_federal_holidays', F5]
Dynamic Date Exclusion
To exclude dynamic dates, use wildcards * in place of a day, month, or year. Wildcards can be combined.
Examples:
*-10-*: Excludes every 10th of any month.04-*-2026: Excludes all days in April 2026.
PHP Date Groups
You can create date groups in PHP to be referenced by the exclude parameter. This is useful for bulk, recurring exclusions such as federal holidays.
Example – US Federal Holidays
Formula
datediff ( F1, F2, exclude='us_federal_holidays' )PHP
add_action('gform_loaded', function() {
// US Federal Holidays
gpac_register_date_group( 'us_federal_holidays', [
'*-01-01', // New Year's Day
'third monday of January', // MLK Jr. Day
'third monday of February', // Presidents' Day
'last monday of May', // Memorial Day
'*-07-04', // Independence Day
'first monday of September', // Labor Day
'second monday of October', // Columbus Day
'*-11-11', // Veterans Day
'fourth thursday of November', // Thanksgiving
'*-12-25', // Christmas Day
] );
});Not sure where to put this PHP? See “Where do I put snippets?” in our documentation for guidance.
Time-Based
Difference Between Times – timediff()
timediff() returns the difference between two times.
Show Details
Sample Usage
timediff( F1, F2 )timediff( datetime ( F1, F2 ), datetime ( F3, F4 ), unit='seconds' ) / 3600Syntax
timediff( start, end, unit='hours', tz='site', dstAware=false )start– The start time value. Accepts direct values, field references, the current time, or a date & time combination.end– The end time value. Accepts direct values, field references, the current time, or a date & time combination.- Optional parameters for customizing the main function.
| Parameters | What It Does | Accepted Values |
|---|---|---|
unit='value' | Sets base unit for the function | seconds, minutes, hours (default) |
tz='value' | Sets the base timezone for the function | site (default, uses WordPress timezone), IANA string (e.g. America/Chicago), or field reference |
dstAware=value | Handles Daylight Savings Time switches | true, false (default), or field reference |
abs='value' | Returns the absolute value | true (default), false, or field reference |
Example
In the below example, the returned value is 8.
timediff( '9:00am', '5:00pm' )Date & Time Combination – datetime()
datetime() combines a date and time value into a unified date & time timestamp. This timestamp is always in seconds.
Show Details
Sample Usage
datetime( F1, F2 )Syntax
datetime( date, time, tz='site' )date– The date value. Accepts field references, static dates, or the current date.time– The time value. Accepts field references or static dates.tz– Optional argument for setting a timezone. Accepts IANA timezone names or field references. Defaults to the site’s timezone.
Example
In the below example, the returned value is 1,777,608,000.
datetime( '2026-05-01', '12:00am', tz='America/New_York' )In the below example, the returned value is 1,777,593,600.
datetime( '2026-05-01', '12:00am', tz='UTC' )Timezone Conversion – converttz()
converttz() converts a time between timezones. Returned value is always in seconds.
Show Details
Sample Usage
converttz( F1, 'UTC' )converttz( F1, 'UTC', fromTz='America/New_York' )Syntax
converttz( value, toTz, fromTz='site' )value– The time in the source timezone. Accepts direct values or field references.toTz– The target timezone. Accepts IANA string or field reference.fromTz– The source timezone. Defaults to the site’s timezone. Accepts IANA string or field reference.
Example
In the below example, the returned value is 21,600. This is the amount of seconds in 6 hours, which is the time difference between Berlin and New York.
converttz( now(), 'Europe/Berlin', fromTz='UTC' ) - converttz( now(), 'America/New_York', fromTz='UTC' )Aggregation & Statistics
Average – average
average returns the average value of the arguments given.
Show Details
Sample Usage
average( F1, F2, 26 )average( 1, 2, 3, 4, F1 )Syntax
average( value1, [value2, ...] )value1– The first value or field to evaluate when calculating the average value.value2, ...(optional) – Additional values or fields to evaluate when calculating the average value.
Example
In the below example, the returned value is 35.
average( 12, 58, 35 )Maximum – max
max returns the largest value in the list of arguments.
Show Details
Sample Usage
max( F1, F4, 67 )max( 108, F7 )Syntax
max( value1, [value2, ...] )value– The first value or field to evaluate when calculating the maximum value.[value2, ...]– (optional) – Additional values or fields to evaluate when calculating the maximum value.
Example
In the below example, the retuned value is 49.
max( 36, 49 )Minimum – min
min returns the smallest value in the list of arguments.
Show Details
Sample Usage
min( F3, 56, F8 )min( 3, F1 )Syntax
min( value1, [value2, ...] )value– The first value or field to evaluate when calculating the minimum value.[value2, ...]– (optional) – Additional values or fields to evaluate when calculating the minimum value.
Example
In the below example, the retuned value is 6.
min( 18, 6 )Logarithms & Exponents
Exponential – exp
exp returns e^x, where e is Euler’s number (~2.718) and x is the provided value.
Show Details
Sample Usage
exp( 25.4 )exp( F1 )Syntax
exp( value )value– The exponent to raise e to.
Example
In the below example, the retuned value is 148.4131591025766.
exp( 5 )Logarithm – log
log returns the logarithm of a number, base 10.
Show Details
Sample Usage
log( 7 )log( F2 )Syntax
log( value )value– The value to calculate the logarithm, base 10.valuemust be positive.
Example
In the below example, the retuned value is 1.6901960800285136.
log( 49 )Natural Logarithm – ln
ln returns the logarithm of a number, base e. e is Euler’s number (~2.718).
Show Details
Sample Usage
ln( 23 )ln( F4 )Syntax
ln( value )value– The value to calculate the logarithm, base e.valuemust be positive.
Example
In the below example, the retuned value is 6.19644412779452.
ln( 491 )Square Root – sqrt
sqrt returns the square root of a number.
Show Details
Sample Usage
sqrt( F12 )sqrt( 72 )Syntax
sqrt( value )value– The number to calculate the square root.
Example
In the below example, the retuned value is 12.
sqrt( 144 )Financial
Future Value – fv
fv calculates the future value of an investment based on constant-amount periodic payments and a constant interest rate.
Show Details
Sample Usage
fv( F1, F2/12, F3, 10000, 1 )fv( 0.05, 10, F1, F2 )Syntax
fv( rate, numberOfPeriods, paymentAmount, presentValue, [endOrBeginning] )rate– The annualized rate of interest.numberOfPeriods– The number of payments to be made.paymentAmount– The amount per period to be paid.presentValue– The current value of the investment.[endOrBeginning]– (optional – 0 by default) – Whether payments are due at the end (0) or beginning (1) of each period.
Units must be consistent for rate, number_of_periods, and payment_amount. For example, on a 60 month car loan this is paid monthly, the rate should be divided by 12 and the numberOfPeriods is 60. If the same loan was instead paid quarterly, the rate should be divided by 4 and the numberOfPeriods is 20.
Example
In the below example, the retuned value is 0.023.
fv( 0.0311, 60, 450, -25000, 0 )By default fv calculates a loan. To use it to calculate a growing investment, add a minus before the formula. For example:
-( fv( 0.08, 5, 300, 2500 ) )
Trigonometry
Arccosine – acos
acos returns the arccosine of a number in radians.
Show Details
Sample Usage
acos( 1 )acos( F2 )Syntax
acos( value )value– The value for which to return the arccosine.
Example
In the below example, the retuned value is 0.
acos( 1 )Arcsine – asin
asin returns the arcsine of a number in radians.
Show Details
Sample Usage
asin( 1 )asin( F2 )Syntax
asin( value )value– The value for which to return the arcsine.
Example
In the below example, the retuned value is 1.5707963267948966.
asin( 1 )Arctangent – atan
atan returns the arctangent of a given number in radians.
Show Details
Sample Usage
atan( 1 )atan( F2 )Syntax
atan( value )value– The value for which the arctangent should be returned.
Example
In the below example, the retuned value is 0.7853981633974483.
atan( 1 )Cosine – cos
cos returns a value between -1 and 1 representing the cosine of the given angle in radians.
Show Details
Sample Usage
cos( 1 )cos( F2 )Syntax
cos( value )value– The value for which to return the cosine.
Example
In the below example, the retuned value is 0.5403023058681398.
cos( 1 )Sine – sin
sin returns a number between -1 and 1 which represents the sine of the given angle in radians.
Show Details
Sample Usage
sin( 1 )round( F2 )Syntax
sin( value )value– The value for which to return the sine.
Example
In the below example, the retuned value is 0.8414709848078965.
sin( 1 )Tangent – tan
tan returns a numeric value that represents the tangent of the given angle.
Show Details
Sample Usage
tan( 1 )tan( F2 )Syntax
tan( value )value– The value for which to return the tangent.
Example
In the below example, the retuned value is 1.5574077246549023.
tan( 1 )Constants
Pi – pi()
pi() returns the value of pi to 20 decimal places.
Show Details
Sample Usage
pi()Syntax
pi()Example
In the below example, the retuned value is 3.14159265358979323846.
pi()Current Date – today()
today() returns the current day’s midnight Unix timestamp. Intended for date-level calculations.
Show Details
Sample Usage
today()datetime( today(), '01:00pm' )Syntax
today()Example
On May 19th 2026, the returned value was 1,779,148,800.
Current Time – now()
now() returns the current time as a Unix timestamp. Intended for time-level calculations.
Show Details
Sample Usage
now()Syntax
now()Example
On May 19th 2026 at 10:28am EDT, the returned value was 1,779,200,911.
Integrations
Invoicing Templates by Gravity PDF
GP Advanced Calculations integrates with Gravity PDF’s Invoicing 2.0+ templates. These templates allow for business-ready invoice generation from Gravity Forms submissions. They’re highly customizable, translatable, support conditional logic, and are GST/VAT compatible. This integration allows for GP Advanced Calculations’ mathematical functions and formulas to be leveraged while working with Gravity PDF’s Invoicing templates.
There’s a variety of sleek templates to choose from and all templates integrate with GP eCommerce Fields, GP Inventory, GP Conditional Pricing, GP Unique ID, and GP Price Range. Learn more about Gravity PDF’s invoicing templates here.
Developer’s Notes
- The following functions return timestamps based on Unix time:
now()today()datetime()converttz()
age(),weekdays(), andweekenddays()are pre-configured aliases ofdatediff().
Known Limitations
-
Single and double quotes cannot be escaped in string-based conditions.
-
Solution: Wrap the string in double quotes if it contains a single quote or single quotes if it contains double quotes.
Example:
'Don't try to escape.'becomes"Don't try to escape."
-
-
When targeting top-level Checkbox fields and Paragraph Text fields in conditional statements, you must use shorthand syntax as Gravity Forms does not listen for these fields in calculations by default.
-
List fields are not supported in calculations.
-
Nested conditional statements are not supported.
-
Solution: Combine the nested conditions into multiple
if/elseif/elsestatements. Here’s an example where we take an unsupported nested conditional statement and convert it into supportedif/elseif/elsestatements.Unsupported:
if( F1 > 10 ): if( F2 > 20 ): 2 else: 1 endif; else: 0 endif;Supported:
if( F1 > 10 && F2 > 20 ): 2 elseif( F1 > 10 && F2 <= 20 ): 1 else: 0 endif;
-
-
By default, a product choice’s value includes both the label and price, formatted as:
Product One|10. This can cause issues when using the product in conditional statements.To resolve this, enable and set a custom value for the choice field. Once set, use the value merge tag modifier to explicitly retrieve the value, as shown below:
if( {Product:1:value} == 'Product One' ): -
When using complex formulas inside
ifstatements, extra spaces between characters can cause the formula to fail, even if it works fine on its own.For example, this standalone formula works as expected:
F1 * (1 + F2)However, when included inside a conditional block with an extra space before the parenthesis, it can fail:
if(F3 == 'Yes'): F1 * (1 + F2) else: 0 endif;In the example above, the space between
*and the(1block can break the formula.Solution (spaces removed):
if(F3 == 'Yes'): F1 *(1 + F2) else: 0 endif;Tip: When embedding formulas in conditional logic, double-check for unintended spaces around
*(,+(, or any operator followed by a parenthesis. -
GP Advanced Calculations only supports numeric results, returning a string value is currently not supported.
-
A calculation cannot contain multiple conditional statements.
Unsupported:
if( F1 > 10 ): 1 else: 0 endif; if( F1 == 5 ): 6 else: 0 endif;Supported:
if( F1 > 10 ): 1 elseif( F1 == 5 ): 6 else: 0 endif; -
Numbers in conditionals can’t be surrounded by quotes.
Unsupported:
if( F1 == '279' ): 4 endif;Supported:
if( F1 == 279 ): 4 endif; -
The
excludeparameter doesn’t support List fields.
Troubleshooting Issues
If the calculations aren’t working as expected, here are some troubleshooting tips you can try.
-
As a first step, ensure that your formula follows all of Gravity Forms’ core calculation rules.
-
Double check this core Gravity Forms rule as it is commonly overlooked:
Fields referenced in a calculation formula (1) must be positioned before the calculation field, and (2) must not be hidden by logic. This is because calculations are rerun during submission using saved values, and if the field hasn’t been saved yet or has been ignored due to logic at form submission, it won’t have a value available for the calculation, leaving the result either incorrect or empty.
-
Use the “Validate Formula” feature that appears directly below the formula setting to ensure that your formula is valid.

-
Make sure there are no JavaScript errors appearing in the browser console, as they can disrupt calculations on the frontend.
-
When referencing the price of a Product field, the merge tag syntax is
{Product:1.2}.
FAQ
How can I create a condition based on the label of a selected choice?
Use the :choice_label merge tag modifier to explicitly get the label from a choice in a formula. (There is also the :label modifier, but it returns the label of the field rather than the selected choice.)
Example:
if ( {Package:1:choice_label} == 'Premium' ) :
{Options:2} * 0.5
else:
{Options:2} * 0.1
endif;How can I use the value and price of a Product field in a calculation?
When working with choice-based Product fields in calculations, use the :price modifier to access the price of the selected choice, and the :value modifier to access the selected option’s value.
Example: The product price increases by 10 if the user selects “First Choice” from a Product field with ID 1.
if ( {Package:1:value} == "First Choice" ):
{Package:1:price} + 10
else:
{Package:1:price}
endif;What is Unix time?
Unix time is a widespread convention for time calculations. It represents the exact number of seconds elapsed since January 1st, 1970 (UTC) until a moment in time.
Usage: Taking both dates and times into consideration and handling timezones in calculations.
Example: 1,779,194,700 was May 19th, 2026 at 12:45pm UTC.
At that time, it was also May 19th, 2026 at 8:45am EDT.
If you were looking for 12:45pm EDT, it would be 1,779,209,100, exactly 14,400 seconds (4 hours) after.
Why is the day/weekday/weekend day count missing a day?
Date-based calculations don’t count the last day (end value) by default. To change this behavior, add the includeEnd=true parameter.
How can I display the current day/time in a readable format?
Advanced Calculations only displays certain functions in a timestamp format based on Unix time. For displaying readable versions of the current date/time, we recommend using this free snippet instead.
Migrating from GP Date Time Calculator
Advanced Calculations now natively supports date and time fields, replacing the functionality previously provided by GP Date Time Calculator. Below is a side-by-side reference for migrating your existing formulas, with an “Even Better” tier showing the cleanest Advanced Calculations equivalent using shorthand field references and dedicated functions.
The examples assume Date fields at IDs 1 and 2, Time fields at IDs 3 and 4, and a Number/Modifier field where noted.
Date Based Calculations
- Old:
{End Date:2} - {Start Date:1} - New:
datediff( {Start Date:1}, {End Date:2} ) - Even Better:
datediff( F1, F2 )
Counting Weekdays
- Old:
{weekdays:{Start Date:1},{End Date:2}} - New:
weekdays( {Start Date:1}, {End Date:2} ) - Even Better:
weekdays( F1, F2 )
Counting Weekend Days
- Old:
{weekendDays:{Start Date:1},{End Date:2}} - New:
weekenddays( {Start Date:1}, {End Date:2} ) - Even Better:
weekenddays( F1, F2 )
Time Based Calculations
- Old:
{End Time:2} - {Start Time:1} - New:
timediff( {Start Time:1}, {End Time:2} ) - Even Better:
timediff( F1, F2 )
Combined Calculations
Hours between two date/time pairs.
- Old:
( {End Date:3} + {End Time:4} ) - ( {Start Date:1} + {Start Time:2} ) - New:
timediff( datetime( {Start Date:1}, {Start Time:2} ), datetime( {End Date:3}, {End Time:4} ) ) - Even Better:
timediff( datetime( F1, F2 ), datetime( F3, F4 ) )
User Modified Calculations
Days between two dates plus a user-entered modifier.
- Old:
{End Date:2} - {Start Date:1} + {Modifier:3} - New:
datediff( {Start Date:1}, {End Date:2} ) + {Modifier:3} - Even Better:
datediff( F1, F2 ) + F3
Calculating Age
- Old:
{Date of Birth:1:age} - New:
age( {Date of Birth:1} ) - Even Better:
age( F1 )
Current Date and Time Calculations
- Old:
{Date:1} - {today} - New:
datediff( today(), {Date:1} ) - Even Better:
datediff( today(), F1 )
Translations
You can use the free Loco Translate plugin to create translations for any of our Perks. If you’ve never used Loco translate before, here’s a tutorial written for beginners.
Hooks
Gravity Forms has hundreds of hooks. Check out our Gravity Forms Hook Reference for the most thorough guide to Gravity Forms’ many actions and filters.
Related Resources
- Add Numeric Values to Gravity Forms Choice Fields for Calculations
Make user selections influence calculations by assigning numerical values to your Choice fields. - How to Build a Loan Calculator in Gravity Forms
Learn the building blocks of creating customized calculators in Gravity Forms with a very complete loan formula powered by GP Advanced Calculations. - How to Do Calculations with Gravity Forms
If you’re using Gravity Forms on your WordPress website, you might need an easy way to do Gravity Forms calculations on form fields and user submissions. - How to Perform Date and Time Calculations in Gravity Forms
Calculate days between dates, count working days, track time differences, and more — all using Advanced Calculations’ built-in date and time functions. - How to Set Up Dynamic Pricing in Gravity Forms
Make your prices mathe-magically adapt to customer input! - Spotlight: Building a Loan Calculator with GP Advanced Calculations
See how James Roberts built a loan calculator for an auto-financing company using GP Advanced Calculations. - Spotlight: Building a Salary Survey with Gravity Forms
Kay Smoljak used Gravity Forms and Gravity Perks to build a survey form that collects anonymous salary data, helping documentarians negotiate fair pay. - Spotlight: Creating Dynamic, Customizable Quoting Forms with Jennifer Erdman
We explore how Jennifer Erdman built a quote calculator — based on highly customizable product offerings — step by step. - Spotlight: Diviguy's Cloud Hosting Cost Calculator
See how Diviguy.com uses Advanced Calculation's conditional formulas to tackle complex monthly cloud hosting pricing logic with ease. - Spotlight: Gasol Foundation Incentivizes Donations with a Tax Break Calculator
See how Jordi Anglada built a tax break calculator to encourage donations for The Gasol Foundation, without knowing how to code. - Spotlight: Multi-Platform Subscription Flows with API Alchemist
Jeff put aside a working middleware solution in favor of keeping his workflow magic in-house, all while saving money and not writing a single line of code. - Spotlight: Powering Up Cost Estimate Forms with Advanced Calculations
Jessica Carter took a free estimate calculator from zero to hero with GP Advanced Calculations. - Spotlight: Turning Gravity Forms Into a Complete Hiring Platform
See how David Kendall worked his magic with Gravity Forms and Gravity Perks to build a complete recruiter CRM. - Spotlight: Works Digital's Magic Land Value Calculation Formula
Works Digital built a land income calculator as a marketing tool for one of their customers. See how it makes sorcerous use of GP Advanced Calculations.



