I have the following SQL query which gives me the total number of hours from one of my meta fields in time format;
SELECT TIME_FORMAT(SEC_TO_TIME(SUM(TIME_TO_SEC(wp_frm_item_metas.meta_value))),'%H:%i' ) AS total_hours FROM wp_frm_item_metas WHERE 1=1 AND wp_frm_item_metas.field_id = '103'
If I wanted to extend this further to take account of the date that the hours were worked which is stored under wp_frm_item_metas.meta_value WHERE wp_frm_item_metas.field_id = '84' to only calculate the hours from the above within the last 1 month using something like
DATE_SUB(DATE(NOW()), INTERVAL 1 MONTH)
How can I build that into the query please?
I should add that the relationship here is that both field_id mentioned above share the same item_id as in wp_frm_item_metas.item_id
What ever I try I cannot seem to get it to work frustratingly !!
Thanks in advance