Sum GravityMath values for today, a custom date range, or a rolling window
The filter parameter of the [gravitymath] shortcode can compare each entry’s creation date with a date such as 2026-10-12 or a word such as -7 days, so a total covers only that period. The examples add up the Order total field (ID 1) of form 13. Replace 13 with your form’s ID and {Order total:1} with the merge tag of your field. The same filters work with scope="view" and scope="visible", and Math filters explains the rest of the filter syntax.
How the date filter works #
filter_date_createdholds the date, andop_date_createdsays how to compare it:gtkeeps the entries created after it, andltkeeps the entries created before it. Neither keeps an entry created at that exact second.- GravityMath understands dates written as
YYYY-MM-DD, a time after the date (2026-10-12 23:59:59), and words such asyesterdayor-7 days. A date without a time means midnight. - Gravity Forms stores the date an entry was created in UTC, and the filter reads your date as UTC too. On a site in another time zone, see Use your site’s time zone.
Because gt leaves out the exact second, the examples start at the last second of the day before (23:59:59), so an entry created at midnight is counted.
Sum today’s entries #
[gravitymath scope="form" id="13" filter="filter_date_created=yesterday 23:59:59&op_date_created=gt"]{Order total:1}[/gravitymath]This adds up the entries created after 23:59:59 yesterday, which are the entries created today.
Sum entries between two dates #
A range needs two conditions on the same date. When a key such as filter_date_created appears twice in filter, GravityMath uses only the last one. Write the second condition with your form’s ID and a colon before the field name, as in filter_13:date_created, and GravityMath applies both. This needs GravityMath 2.12.3 or later.
[gravitymath scope="form" id="13" filter="filter_date_created=2026-10-12 23:59:59&op_date_created=gt&filter_13:date_created=2026-10-16&op_13:date_created=lt"]{Order total:1}[/gravitymath]This adds up the entries created on October 13, 14 and 15, 2026: after the last second of October 12 and before midnight at the start of October 16. Put your form’s ID in both filter_13:date_created and op_13:date_created. With scope="view", use the ID of the form the View is built on.
Modifiers work over the range too: {Order total:1:avg} gives the average order total for those days, and {Order total:1:count} the number of orders.
Sum a rolling window or a calendar period #
Put one of these values in place of the filter value of the today example:
| Entries created | filter value |
|---|---|
| In the last 7 days, counted back from the current time | filter_date_created=-7 days&op_date_created=gt |
| In the last 30 days, counted back from the current time | filter_date_created=-30 days&op_date_created=gt |
| Today and the 6 days before | filter_date_created=-7 days 23:59:59&op_date_created=gt |
| This month | filter_date_created=last day of last month 23:59:59&op_date_created=gt |
| Last month | filter_date_created=last day of -2 months 23:59:59&op_date_created=gt&filter_13:date_created=first day of this month 00:00&op_13:date_created=lt |
| This year | filter_date_created=last day of december last year 23:59:59&op_date_created=gt |
This shortcode adds up the last 7 days:
[gravitymath scope="form" id="13" filter="filter_date_created=-7 days&op_date_created=gt"]{Order total:1}[/gravitymath]A word for a day, such as first day of this month, keeps the current time of day unless the value gives a time, so each calendar row in the table ends with 23:59:59 or 00:00.
Use your site’s time zone #
Words such as yesterday and the dates you type are read as UTC. On a site set to New York time, the UTC day begins at 8 p.m. New York time the evening before (7 p.m. in winter), so the total for today also counts that evening’s entries.
To count from midnight in your time zone, add the time zone name after each date you type:
[gravitymath scope="form" id="13" filter="filter_date_created=2026-10-12 23:59:59 America/New_York&op_date_created=gt&filter_13:date_created=2026-10-16 America/New_York&op_13:date_created=lt"]{Order total:1}[/gravitymath]For today, use the Gravity Forms merge tag {date_mdy}, which gives today’s date in the site’s time zone, followed by the time zone name and -1 second:
[gravitymath scope="form" id="13" filter="filter_date_created={date_mdy} America/New_York -1 second&op_date_created=gt"]{Order total:1}[/gravitymath]- Use your site’s time zone. In WordPress, go to Settings, then General, and look at Timezone: the choice New York under America is written
America/New_York. - A time zone after a word, as in
today America/New_York, gives the wrong day for some hours of each day, because the date is taken from UTC before the time zone is applied. Use{date_mdy}for today. - For the entry date, use
{date_mdy}and not{date_dmy}: GravityMath reads an entry date with slashes as month/day/year. - A UTC offset with a plus sign, such as
+02:00, does not work, because the filter reads the plus sign as a space. Use the time zone name. -7 daysand-30 dayscount back from the current time, so they need no time zone.
Filter by a Date field instead of the entry date #
To total by a Date field in the form, such as a delivery date, use the field’s ID in place of date_created. A Date field holds a date without a time, so gt and lt compare whole days. This adds up the orders delivered on October 13, 14 and 15, with a Date field (ID 3) set to dd/mm/yyyy:
[gravitymath scope="form" id="13" filter="filter_3=12/10/2026&op_3=gt&filter_13:3=16/10/2026&op_13:3=lt"]{Order total:1}[/gravitymath]Write the date in the field’s own format, as set in the form editor, or as YYYY-MM-DD. Words such as today don’t work on a Date field. For today’s date, use {date_mdy} when the field’s format starts with the month, and {date_dmy} for any other format:
[gravitymath scope="form" id="13" filter="filter_3={date_dmy}"]{Order total:1}[/gravitymath]Troubleshooting #
The total is 0, or the total of every entry
GravityMath did not read the date. It reads an entry date with slashes as month/day/year, so 16/10/2026 is not a date, and 12/10/2026 means December 10. A date it cannot read becomes January 1, 1970: lt then matches no entry and gt matches every entry. Write dates as YYYY-MM-DD.
The total prints nothing
With scope="view" or scope="visible", a total whose filter matches no entry prints nothing, so a total for today stays empty until the first entry of the day. The same total with scope="form" prints 0. Adding notices="true" to the shortcode shows visitors an asterisk where the total would be, and the line “* Results may not be accurate.” at the end of the page content. The [gravitymath] shortcode describes notices and the filters that change its text.
A range total includes entries outside the range
GravityMath skipped the second condition. Check that the number before the colon in filter_13:date_created is your form’s ID, and update GravityMath if it is older than 2.12.3. With debug="true" on the shortcode and ?nocache=1 added to the page’s address, the debug report names a filter it skipped.
The total for today includes the evening before
Your site is not set to UTC. The section Use your site’s time zone shows how to count from your own midnight.