Meta_query and doing a SUBSTR compare on a custom date field
-
Is this possible or would I have to create SQL specifically for this?
I want to do a query that is based on the value in a custom date field and I want to check for three scenarios based on my URL:
1. YYYY
2. YYYY-mm
3. YYYY-mm-dd
So I want to peform the equivlant of this on that custom field:
1. wp_postmeta.meta_key = ‘event-date’ AND SUBSTR(wp_postmeta.meta_value,1,4) = ‘2012’)
2. wp_postmeta.meta_key = ‘event-date’ AND SUBSTR(wp_postmeta.meta_value,1,7) = ‘2012-02’)
3. wp_postmeta.meta_key = ‘event-date’ AND SUBSTR(wp_postmeta.meta_value,1,10) = ‘2012-02-01’)I don’t think the allowed operators will accomodate this type of action but I’d rather not create custom SQL if I can avoid it.
Any help will be greatly appreciated.
- The topic ‘Meta_query and doing a SUBSTR compare on a custom date field’ is closed to new replies.