How to Create Time-Based Date Filters in Bold Reports
Bold Reports offers robust tools for selecting time-based data using Date Filters and expressions, enabling users to filter data by specific dates or ranges effectively. Date Filters allow users to apply filters in reports to showcase data for specific periods, such as daily, weekly, monthly, or yearly intervals. Expressions enhance customization by enabling calculations, data formatting, and the creation of new fields or modifications to existing data displays within a report. To utilize these features, users can create parameters for the desired date or date range and apply expressions to filter report data dynamically. These tools are particularly useful for generating custom reports that focus on targeted time periods, providing flexibility and precision. This article provides a step-by-step guide to creating time-based date filters in Bold Reports, showcasing how to leverage these features for dynamic reporting.
Getting Today:
To get the date for today, use the following expression:
=Today()
Getting Yesterday:
To get the date for yesterday, use the following expression:
=DateAdd("d", -1, Today())
Getting Last Seven Day’s Date:
To get the date for the last seven days, use the following expression:
=DateAdd("d", -7, Today())
Getting Last 30 Day’s Date:
To get the date for the last seven days, use the following expression:
=DateAdd("d", -30, Today())
Current Month First Date:
To get the first date of the current month, use the following expression:
=DateAdd("m", 0, DateSerial(Year(Today()), Month(Today()), 1))
Current Month Last Date:
To get the last date of the current month, use the following expression:
=DateAdd("m", 0, DateSerial(Year(Today()), Month(Today()) + 1, 0))
Last Month First Date:
To get the first date of the previous month, use the following expression:
=DateAdd("m", -1, DateSerial(Year(Today()), Month(Today()), 1))
Last Month Last Date:
To get the last date of the previous month, use the following expression:
=DateAdd("m", 0, DateSerial(Year(Today()), Month(Today()), 0))
Current Year First Date:
To get the first date of the current year, use the following expression:
=DateSerial(Year(Today), 1, 1)
Current Year Last Date:
To get the last date of the current year, use the following expression:
=DateSerial(Year(Today), 12, 31)
Last Year First Date:
To get the first date of the previous year, use the following expression:
=DateAdd("yyyy", -1, DateSerial(Year(Today), 1, 1))
Last Year Last Date:
To get the last date of the previous year, use the following expression:
=DateAdd("d", -1, DateSerial(Year(Today()), 1, 1))
By incorporating these expressions into your reports, you can effectively filter data based on specific time periods, such as today, yesterday, the last seven days, last thirty days, the current month, or the previous month, the current year, or the previous year.
Instructions to Use Date Filters in Reports:
- Create a parameter named “DateFilterParam” of type “DateTime” and specify the available values as in the following snap.
- Drag and drop textboxes for StartDate and EndDate and set them using the following expressions and preview the report.
StartDate:
=Switch(Parameters!DateFilterParam.Value = "Today", Today(),
Parameters!DateFilterParam.Value = "Yesterday", DateAdd("d", -1, Today()),
Parameters!DateFilterParam.Value = "Last 7 Days", DateAdd("d", -7, Today()),
Parameters!DateFilterParam.Value = "Last 30 Days", DateAdd("d", -30, Today()),
Parameters!DateFilterParam.Value = "This Month", DateAdd("m", 0, DateSerial(year(Today), month(Today), 1)),
Parameters!DateFilterParam.Value = "Last Month", DateAdd("m", -1, DateSerial(year(Today), month(Today), 1)),
Parameters!DateFilterParam.Value = "This Year", DateSerial(Year(Today), 1, 1),
Parameters!DateFilterParam.Value = "Last Year", DateAdd("yyyy", -1, DateSerial(year(Today), 1, 1))
)
EndDate:
=Switch(Parameters!DateFilterParam.Value = "Today", Today(),
Parameters!DateFilterParam.Value = "Yesterday", DateAdd("d", -1, Today()),
Parameters!DateFilterParam.Value = "Last 7 Days", Today(),
Parameters!DateFilterParam.Value = "Last 30 Days", Today(),
Parameters!DateFilterParam.Value = "This Month", DateAdd("m", 1, DateSerial(year(Today), month(Today), 0)),
Parameters!DateFilterParam.Value = "Last Month", DateAdd("m", 0, DateSerial(year(Today), month(Today), 0)),
Parameters!DateFilterParam.Value = "This Year", DateSerial(Year(Today), 12, 31),
Parameters!DateFilterParam.Value = "Last Year", DateAdd("d", -1, DateSerial(year(Today), 1, 1))
)
- Now, select the parameter value to set the range and view the report. By utilizing these date filters and expressions, you can enhance your reporting capabilities and retrieve data based on custom time ranges.