CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Filtering date by month (only) in a report or view, how?
Pages: [1]

Author Topic: Filtering date by month (only) in a report or view, how?  (Read 1694 times)

CiviTeacher.com

  • I live on this forum
  • *****
  • Posts: 1282
  • Karma: 118
    • CiviTeacher
  • CiviCRM version: 3.4 - 4.5
  • CMS version: Drupal 6&7, Wordpress
  • MySQL version: 5.1 - 5.5
  • PHP version: 5.2 - 5.4
Filtering date by month (only) in a report or view, how?
March 28, 2012, 11:50:37 am
I have a situation where I need an exposed date filter for a Drupal view or CiviCRM report that filters only by Month.

The point of this is to show date data (a custom date field called 'anniversary') that fall in a given month, regardless of if the date is on the 1st or the 29th, or year 1951 or year 1991.

The client would select from a dropdown "April" and the result would be everyone with a date in April, see what I mean?

I have noticed this is not available in the standard Drupal view filters that I can see.  Nor is it a civiCRM date field filter in reports. 

Any ideas for best practices or starting points?

Any ideas for modules or code?
« Last Edit: March 28, 2012, 11:52:35 am by Stoob »
Try CiviTeacher: the online video tutorial CiviCRM learning library.

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: Filtering date by month (only) in a report or view, how?
March 29, 2012, 10:09:49 am
I could suggest two potential approaches.

First is to use the built in date range exposed filter in Views and then use jQuery (from your theme or a module) to hide the controls and replace them with a dropdown of months. Then when that control is changed, the jQuery would update the date range controls with the corresponding values.

Second idea is to use a custom module, then you can have whatever filters you want because it's all custom.
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Filtering date by month (only) in a report or view, how?

This forum was archived on 2017-11-26.