Filtering by the week of the year

Filter your GravityView entries to show only records from specific weeks of the year using the GravityView Advanced Filtering Extension and the {today} merge tag.

Overview

This guide explains how to set up automatic week-based filtering in GravityView, allowing your View to automatically display entries that match the current week number of the year.

Use case

This filtering method is particularly useful for:

  • Assignment tracking systems where tasks are organized by weekly periods
  • Schedule management where activities are planned on a weekly basis
  • Reporting dashboards that need to display current week's data automatically
  • Team calendars where users need to see their weekly assignments

How week numbering works

The week filtering system uses the ISO-8601 week numbering standard:

  • Weeks are numbered from 1 to 52 (or 53 in some years)
  • Week 1 is the first week with a Thursday in the new year
  • Weeks start on Monday and end on Sunday
  • The week number represents the week's position in the calendar year

For example:

  • January 1-7 falls on Week 1
  • July 1-7 typically falls in Week 26 or 27
  • December 25-31 typically falls in Week 52

Requirements

To implement week-based filtering, you need:

  1. Gravity Forms plugin installed and activated
  2. GravityView plugin installed and activated
  3. GravityView Advanced Filtering Extension

Step-by-step setup

Step 1: Configure your form's Week Number field

Your Gravity Forms form needs to have a Number field configured for week numbers:

  1. Edit your form in Gravity Forms.
  2. Add a Number field labeled "Week Number" (or similar).
  3. Configure the Number field settings:
    • Check the "Enable Calculation" checkbox.
      • Leave Formula empty.
      • Set "Rounding" to 0 (only shown when Enable Calculation is checked.
    • In the Range setting, set "Min" to 1 and "Max" to 53.
    • Under "Rules", Consider making this field required if week assignment is mandatory.
    • Optionally, add Description: "Enter the week number (1-52) for this assignment."
    • If you want the current week to be pre-populated, scroll down to the "Advanced" section and click to expand it.
    • Set Default Value to {today:format:W}, which uses the {today} merge tag.

Then save your form.

Form settings for week number input, allowing entry 1-52, with calculation enabled and no duplicate rule

The Advanced tab:

Admin field setup with default value for current week number
Using the {today} merge tag to prepopulate the current week number

Tip: You can also pre-populate this field with the current week using dynamic population.

Step 2: Enable Advanced Filtering

Configure the GravityView Advanced Filtering Extension to filter entries automatically:

  1. Install and activate Advanced Filtering by following this guide.
  2. In the View, scroll to the Settings metabox
  3. Click the Filter & Sort tab
  4. Under Advanced Filter, click Add Condition
  5. Add a new filter condition:
    • Field: Select the form's Week Number field
    • Operator: is
    • Value: {today:format:W}
  6. Save the View

When configured, the filter should look like this:

Advanced filter settings: Filter entries by the current week number using the condition "Week Number is {today:format:W}"

What's the deal with the {today:format:W} merge tag? Let's take a closer look.

Dynamic week filtering with merge tags

Automatic current week filtering

To automatically show only the current week's entries, use the {today}  merge tag with the :format  modifier:

{today:format:W}

This merge tag:

  • Retrieves today's date
  • Formats it using PHP's W  format specifier
  • Returns the current week number (1-52)

Note: Learn more about the {today}  merge tag and its formatting options in the Gravity Forms documentation. For a complete reference of date format characters, see the WordPress date and time formatting guide.

To implement:

  1. In the Advanced Filtering settings, set the filter value to: {today:format:W}
  2. The View automatically displays only entries matching the current week.
  3. The filter updates automatically as weeks change.

Example scenario

On January 1st (Week 1):

  • Filter value: {today:format:W}  resolves to 1
  • Only entries with Week Number = 1 are displayed.

On July 15th (Week 29):

  • Filter value: {today:format:W}  resolves to 29
  • Only entries with Week Number = 29 are displayed.

Advanced configuration options

Combine with other filters

You can combine week filtering with other criteria:

Week Number is {today:format:W}
AND
Status is "Active"
AND
Assigned To is {user:ID}

Create week range filters

For viewing multiple weeks:

Week Number is greater than or equal to {today:format:W}
AND
Week Number is less than or equal to {today:format:W|+2}

This shows the current week plus the next two weeks.

Previous/next week views

Create links to navigate between weeks:

  • Previous week?filter_week={today:format:W|-1}
  • Current week?filter_week={today:format:W}
  • Next week?filter_week={today:format:W|+1}

Custom week display

To display the week number in your View:

  1. Add a Custom Content field.
  2. Use merge tags: Week {Week Number:1} of {today:format:Y}
  3. Result: "Week 15 of 2024"

Troubleshooting

Common issues and solutions

Entries not filtering correctly:

  • Verify the Week Number field is a Number field type in your form.
  • Ensure the field contains numeric values (1-52 or 1-53).
  • Check that Advanced Filtering is enabled in your View.
  • Confirm the merge tag {today:format:W}  is formatted correctly.

Wrong week number displayed:

  • Confirm your server's timezone settings match your intended timezone.
  • Check PHP date configuration on your server.
  • Verify the week numbering system matches ISO-8601 standards.

No entries showing when filter is applied:

  • Check if any entries exist for the current week number.
  • Verify the Week Number field has been properly populated in your form submissions.
  • Test with a specific week number instead of the merge tag to isolate the issue.
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us