Jump to content

Selector by month, not by year


bbb
 Share

Recommended Posts

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.

  • Like 4
Link to comment
Share on other sites

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

  • Like 2
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...