bbb Posted October 24, 2018 Posted October 24, 2018 How might one structure a selector if one wanted to find pages that had a date within a specific month but regardless of year?
Robin S Posted October 24, 2018 Posted October 24, 2018 Not easy using the core Datetime field type alone AFAIK. The DatetimeAdvanced module by @BitPoet supports querying by month, but see the notes about timezone support in the module readme. An alternative would be to add a hidden integer field to the template and save the month number to that in a saveReady hook, then use that field in your selector. 4
flydev Posted October 25, 2018 Posted October 25, 2018 Another idea depending the number of data you got (anyway, not really a criteria here), you could also use RockFinder by @bernhard and custom queries using MySQL EXTRACT function with subquery. # pseudo-query SELECT pages.id FROM ( sub_query ) WHERE EXTRACT(MONTH FROM DATE( subquery_here ) ); Quote EXTRACT(unit FROM date) The EXTRACT() function uses the same kinds of unit specifiers as DATE_ADD() or DATE_SUB(), but extracts parts from the date rather than performing date arithmetic. https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_extract 2
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now