# How to filter all events with precise dates?

**URL:** <https://gramps.discourse.group/t/how-to-filter-all-events-with-precise-dates/4422>\
**Category:** Help\
**Tags:** new\_filter\_rules\
**Created:** [November 18, 2023, 7:09pm UTC](https://gramps.discourse.group/t/how-to-filter-all-events-with-precise-dates/4422 "2023-11-18T19:09:15Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![emyoulation](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/emyoulation/32/67_2.png) [@emyoulation](https://gramps.discourse.group/u/emyoulation)\
**Post date:** [December 30, 2023, 10:44pm UTC](https://gramps.discourse.group/t/how-to-filter-all-events-with-precise-dates/4422/7 "2023-12-30T22:44:44Z")

</div>

Ok, here are 2 custom filters generated by SuperTool scripts. (And you have to have the [SuperTool](https://www.gramps-project.org/wiki/index.php/Addon:Isotammi_addons#SuperTool) addon installed because [it provides functionality that might be needed for the Custom Filters](https://github.com/Taapeli/isotammi-addons/blob/master/source/SuperTool/README.md#saving-the-query-as-a-custom-filter). Such as custom properties shortcuts that you might have used in the Script.) If you don’t want to install the Custom Filters using the scripts, you can paste the filter definition into the `custom_filters.xml` file. (As described in “[Sharing custom filters](https://gramps.discourse.group/t/sharing-custom-filters/997)”.)

- **SuperTool\_IrregularDates** - Finds Events with inexact dates
- **SuperTool\_RegularDates** - Find Events with _ **complete** _ dates - validated with a day, month _and_ year. (No spans or ranges)

 

In [Gramps User Directory](https://www.gramps-project.org/wiki/index.php/Gramps_Glossary#user_directory)’s **Gramps51** folder, `custom_filters.xml`

```python
<?xml version="1.0" encoding="utf-8"?>
<filters>
  <object type="Event">
    <filter name="SuperTool_RegularDates" function="and">
      <rule class="GenericFilterRule_Event" use_regex="False">
        <arg value="dateobject.is_regular()"/>
        <arg value="# Return &quot;True&quot; if the date is a regular date.&lt;br&gt;# The regular date is a single exact date, i.e. not text-only, not a range or a span, &lt;br&gt;# not estimated/calculated, not about/before/after date, and having a year, &lt;br&gt;# month, and day all non-zero.&lt;br&gt;# see https://gramps-project.org/docs/gen/gen_lib.html#gramps.gen.lib.date.Date.is_regular"/>
        <arg value="dateobject=self.event.get_date_object()"/>
      </rule>
    </filter>
    <filter name="SuperTool_IrregularDates" function="and">
      <rule class="GenericFilterRule_Event" use_regex="False">
        <arg value="not (event.get_date_object().is_regular() or event.get_date_object().is_empty())"/>
        <arg value="# Return True if matches events having a irregular date but not a blank date)<br># see https://gramps-project.org/docs/gen/gen_lib.html#gramps.gen.lib.date.Date.is_regular"/>
        <arg value="dateobject=self.event.get_date_object()"/>
      </rule>
    </filter>
    <filter name="SuperTool_Blank_Dates" function="and">
      <rule class="GenericFilterRule_Event" use_regex="False">
        <arg value="event.get_date_object().is_empty()"/>
        <arg value="# Return &quot;True&quot; if the date is a blank date."/>
        <arg value="dateobject=self.event.get_date_object()"/>
      </rule>
    </filter>
  </object>
</filters>

```

Or… if you’re up to trying to see how these were built, here’s the _initial_ script where you can “ **File → Open** ” and “ **File → Save as filter** ” when in SuperTool with the **Events** category active. This creates the 1st Custom Filter in the Events category using the text in the `Title` field:

 

```python
[Gramps SuperTool_beta script file]
version=1
[title]
SuperTool_IrregularDates
[category]
Events
[initial_statements]
# Return "True" if the date is a regular date.
# The regular date is a single exact date, i.e. not text-only, not a range or a span, not estimated/calculated, 
# not about/before/after date, and having year, month, and day all non-zero.
# see https://gramps-project.org/docs/gen/gen_lib.html?highlight=is_regular#gramps.gen.lib.date.Date.is_regular
[statements]
dateobject=self.event.get_date_object()
[filter]
not dateobject.is_regular()
[expressions]
type, date, placename, participants, dateobject.is_regular(), description
[scope]
selected
[unwind_lists]
False
[commit_changes]
False
[summary_only]
False

```

 

To create the 2nd Custom Filter, just change the name in the `Title` (from Irregular to Regular) and eliminate the "`not `" at the beginning of the Filter field. Then **`Save as filter`** again.

 ![image](https://global.discourse-cdn.com/free1/uploads/gramps/original/2X/4/498073332f5ae72dc9ae09a6b341b2586fba4065.png)

---

_[View the full topic](https://gramps.discourse.group/t/how-to-filter-all-events-with-precise-dates/4422)._
