How to filter on month only?
This is an open discussion with 4 replies, filed under General.
Search
It's not currently supported unfortunately, a single value will be treated as the year. It's definitely possible though as months are generally 1-2 digits, not 4 (although having said this that would not be true for years 1-12).
I imagine being able to filter by month is a much more common scenario that filtering by the year 1-12.
Could you open an issue?
Seems that the Date field supports regular expression filtering. Might something like this work?
regex:^[0-9]{4}-{$month}-
Hopefully this would resolve to a regex such as this for January:
regex:^[0-9]{4}-01-
Which would hopefully find entries where the date starts with (^
) four numbers ([0-9]{4}
) followed by a hyphen and your month, followed by another hyphen.
I say hopefully because I haven't tried it...
I'm not sure how the filter deals with the curly braces for the regex quantifiers. If that doesn't work you can try something like
regexp:^(1|2)[0-9][0-9][0-9]-{$this-month}-
or not as strict
regexp:^[0-9]*-{$this-month}-
See http://getsymphony.com/discuss/thread/88304/1/#position-3 and http://getsymphony.com/discuss/thread/77/2/#position-40
Thanks so much guys, this worked perfectly! I was even able to get the month variable to not be required by using an asterisk.
regexp:^[0-9]*-{$url-month:*}-
Create an account or sign in to comment.
I know this is a bit of a strange question, but I promise I have a good use case. I want to use a datasource to filter on the month value of a date field, but not the year or the day. What might be syntax look like for this? I thought that
would work fine, even when $year or $day don't have values... but that doesn't seem to be the case. Any other ideas? Thanks for your help.