How to filter a view when day, month and year are separate fields I am trying to filter a view to show content that happened today on this day in previous years.

We have day, month and year fields but they are not dates.

How can I filter on day = today's day and month = today's month without converting them to date fields.

Current fields are:


Day - integer
Month - List (integer)
Year - integer
You can do that with views php. 

Construct your view to take two contextual filters. Do not append any placeholder (%) to the path.

First filter: Add the month field as a contextual filter. Select from the section that reads: When the filter value is not in the url, Provide a default value. A select list Type opens up and from it you select PHP Code and in the PHP contextual filter code you enter:

date('F');


This will match it against today's month in the format of a full string ie. January. Adjust it if your month format is different (if for 3 letter abbrev, use date('M');)

Test this by typing in the month for a node that exists in the Preview with contextual filters text box at the bottom and update preview. It should show you your nodes filtered by month.

Second Filter: Add the day field as a contextual filter, and as above select PHP Code for default value. Add this code:

date('j');


This will filter on the day in the format of 1-31. If you want 01-31 then use date('d');

Test this by typing in the month/day for a node that exists in the Preview with contextual filters text box at the bottom and update preview. It should show you your nodes filtered by month and day.

You can also access the view as such: VIEWPATH/MONTH/DAY and it will show you a result for the values you provided. If you just access the view by VIEWPATH it will give you the result for the date of today.