Search partial date


(Talk) #1

Hey all, just working on a solution to display a list of members whose birthday falls on the day the page is accessed. The date of birth is stored in a metadata field, in the format 'd-m-Y'

 

I was hoping to stick a nested search page in looking for the d-m bits of globals_date. My problem is that unless I also search the Y, nothing matches, even when selecting any instead of all on the matching rule. I can't search every year, so anyone run into something similar before?

 

Running Matrix 5.1.2.1

 

:-) Jeremy


(Bart Banda) #2

I think you'd need to turn on "Enable Contains Search", which will increase the index size of the system quite a bit I think and can slow down searches across the board, you'd then have to re-index as well. 

 

If that is not viable, you could potentially have another metadata field that references the first one and strips the last -Y part using a keyword modifier and search on that value instead, might be a better solution. 


(Talk) #3

Thanks for your reply Bart, I like the second option. One solution I was toying with was to use a datetime trigger to set a metadata value on the day of the birthday, so the search could just search for a constant term, but the problem is the trigger needs d-m-Y h:i:s - to your knowledge, are there any workarounds where I could use globals_date^date-format:Y to replace the Y in the dob field?

 

Jeremy


(Bart Banda) #4

to your knowledge, are there any workarounds where I could use globals_date^date-format:Y to replace the Y in the dob field?

 

 

Not sure what you mean by this?

 

If your current DoBs are stored as d-m-Y, you could easily use a modifier on that to leave you with d-m by using %metadata_field_<dob_field_name>^maxchars:5% 

 

As its safe to assume that you will always have 5 chars for the d-m part, 01-01

 

Does that help? 


(Talk) #5

Thanks, I mean is it possible to use a combination with replacements like that to trigger the metadata time event for a trigger?


(Bart Banda) #6

Thanks, I mean is it possible to use a combination with replacements like that to trigger the metadata time event for a trigger?

 

Don't think so as the metadata time event and condition only work off 1 single metadata date field. 


(Peter McLeod) #7
Hi
 
Not entirely sure how efficient the method I'm outlining below would be (also not how if there would be be any version dependancy), but should return the data you need:
 
Use an asset listing to list all the assets containing the member metadata. 
 
Create a paint layout to apply to the listing's default format.
 
In the layout add a logical condition that returns true if matched - which will be a combination of keywords - one for day part, and one for month part:
 
If the date is stored in metadata as an actual date - the logical conditions would be:
  • asset_metadata_<BirthdayFieldName>^date_format:d^replace_keywords:contains:{globals_date_d}
  • asset_metadata_<BirthdayFieldName>^date_format:m^replace_keywords:contains:{globals_date_m}

You could probably use different modifiers to compare ect but 'contains' should do fine.

 

In layout's formatting, print the name of the person (or whatever) if the condition matches - else do nothing.
 
Thanks
Peter