Create a MYSQL query
Budget: $10 – $30 USD
I need a SELECT statement (not WHERE), that does this:
1. Find a certain string in a data field (arm_next_due_payment)
2. Select a date stamp that arrives a certain number of characters after the string
3. Converts the date stamp to a human-readable date and output it in the QUERY like this: 2023-09-16 (YYYY-MM-DD)
The field data is serialized, but I think you should be able to use REGEXP and/or SUBSTRING to securely fetch the date.
The string to look for is: arm_next_due_payment (this is always the same in all rows)
The date stamp I need in this case is: 1694822400 (this changes from row to row and is the data I am after)
Here is example data for this field:
**********************************************************
a:25:{s:23:"arm_current_plan_detail";a:13:{s:24:"arm_subscription_plan_id";s:1:"3";s:26:"arm_subscription_plan_name";s:23:"Professional Membership";s:33:"arm_subscription_plan_description";s:99:"Regular Membership: Includes all membership benefits as well mailing of the quarterly ITEA Journal.";s:26:"arm_subscription_plan_type";s:9:"recurring";s:29:"arm_subscription_plan_options";s:1119:"a:16:{s:11:"access_type";s:6:"finite";s:12:"payment_type";s:12:"subscription";s:14:"payment_cycles";a:1:{i:0;a:7:{s:9:"cycle_key";s:4:"arm0";s:11:"cycle_label";s:23:"Professional Membership";s:12:"cycle_amount";s:2:"75";s:13:"billing_cycle";s:1:"1";s:12:"billing_type";s:1:"Y";s:14:"recurring_time";s:8:"infinite";s:19:"payment_cycle_order";s:1:"1";}}s:5:"trial";a:5:{s:6:"amount";s:1:"0";s:4:"days";s:1:"1";s:6:"months";s:1:"1";s:5:"years";s:1:"1";s:4:"type";s:1:"D";}s:9:"recurring";a:6:{s:4:"days";i:1;s:6:"months";i:1;s:5:"years";s:1:"1";s:4:"type";s:1:"Y";s:4:"time";s:8:"infinite";s:20:"manual_billing_start";s:15:"transaction_day";}s:13:"cancel_action";s:1:"1";s:18:"cancel_plan_action";s:9:"on_expire";s:3:"eot";s:1:"1";s:12:"grace_period";a:2:{s:11:"end_of_term";s:2:"14";s:14:"failed_payment";s:1:"1";}s:21:"payment_failed_action";s:1:"1";s:31:"enable_upgrade_downgrade_action";s:1:"1";s:13:"upgrade_plans";a:1:{i:0;s:2:"10";}s:14:"upgrade_action";s:9:"immediate";s:15:"downgrade_plans";a:3:{i:0;s:1:"9";i:1;s:1:"8";i:2;s:1:"7";}s:16:"downgrade_action";s:9:"immediate";s:9:"pricetext";s:15:"Free Membership";}";s:28:"arm_subscription_plan_amount";s:2:"75";s:28:"arm_subscription_plan_status";s:1:"1";s:26:"arm_subscription_plan_role";s:8:"armember";s:29:"arm_subscription_plan_post_id";s:1:"0";s:33:"arm_subscription_plan_gift_status";s:1:"0";s:31:"arm_subscription_plan_is_delete";s:1:"0";s:34:"arm_subscription_plan_created_date";s:19:"2021-10-05 17:46:30";s:31:"arm_user_selected_payment_cycle";s:1:"0";}s:14:"arm_start_plan";i:1663351412;s:15:"arm_expire_plan";s:0:"";s:17:"arm_is_trial_plan";i:0;s:15:"arm_trial_start";s:0:"";s:13:"arm_trial_end";s:0:"";s:16:"arm_payment_mode";s:19:"manual_subscription";s:17:"arm_payment_cycle";s:1:"0";s:20:"arm_is_user_in_grace";i:0;s:20:"arm_grace_period_end";s:0:"";s:23:"arm_grace_period_action";s:0:"";s:20:"arm_subscr_effective";s:0:"";s:18:"arm_change_plan_to";s:0:"";s:16:"arm_user_gateway";s:6:"manual";s:13:"arm_subscr_id";s:0:"";s:20:"arm_next_due_payment";s:10:"1694822400";s:23:"arm_completed_recurring";i:1;s:13:"arm_sent_msgs";s:0:"";s:18:"arm_cencelled_plan";s:0:"";s:17:"arm_authorize_net";a:0:{}s:13:"arm_2checkout";a:0:{}s:10:"arm_paypal";a:0:{}s:10:"arm_stripe";a:0:{}s:14:"payment_detail";a:0:{}s:21:"arm_started_plan_date";s:0:"";}
1. Find a certain string in a data field (arm_next_due_payment)
2. Select a date stamp that arrives a certain number of characters after the string
3. Converts the date stamp to a human-readable date and output it in the QUERY like this: 2023-09-16 (YYYY-MM-DD)
The field data is serialized, but I think you should be able to use REGEXP and/or SUBSTRING to securely fetch the date.
The string to look for is: arm_next_due_payment (this is always the same in all rows)
The date stamp I need in this case is: 1694822400 (this changes from row to row and is the data I am after)
Here is example data for this field:
**********************************************************
a:25:{s:23:"arm_current_plan_detail";a:13:{s:24:"arm_subscription_plan_id";s:1:"3";s:26:"arm_subscription_plan_name";s:23:"Professional Membership";s:33:"arm_subscription_plan_description";s:99:"Regular Membership: Includes all membership benefits as well mailing of the quarterly ITEA Journal.";s:26:"arm_subscription_plan_type";s:9:"recurring";s:29:"arm_subscription_plan_options";s:1119:"a:16:{s:11:"access_type";s:6:"finite";s:12:"payment_type";s:12:"subscription";s:14:"payment_cycles";a:1:{i:0;a:7:{s:9:"cycle_key";s:4:"arm0";s:11:"cycle_label";s:23:"Professional Membership";s:12:"cycle_amount";s:2:"75";s:13:"billing_cycle";s:1:"1";s:12:"billing_type";s:1:"Y";s:14:"recurring_time";s:8:"infinite";s:19:"payment_cycle_order";s:1:"1";}}s:5:"trial";a:5:{s:6:"amount";s:1:"0";s:4:"days";s:1:"1";s:6:"months";s:1:"1";s:5:"years";s:1:"1";s:4:"type";s:1:"D";}s:9:"recurring";a:6:{s:4:"days";i:1;s:6:"months";i:1;s:5:"years";s:1:"1";s:4:"type";s:1:"Y";s:4:"time";s:8:"infinite";s:20:"manual_billing_start";s:15:"transaction_day";}s:13:"cancel_action";s:1:"1";s:18:"cancel_plan_action";s:9:"on_expire";s:3:"eot";s:1:"1";s:12:"grace_period";a:2:{s:11:"end_of_term";s:2:"14";s:14:"failed_payment";s:1:"1";}s:21:"payment_failed_action";s:1:"1";s:31:"enable_upgrade_downgrade_action";s:1:"1";s:13:"upgrade_plans";a:1:{i:0;s:2:"10";}s:14:"upgrade_action";s:9:"immediate";s:15:"downgrade_plans";a:3:{i:0;s:1:"9";i:1;s:1:"8";i:2;s:1:"7";}s:16:"downgrade_action";s:9:"immediate";s:9:"pricetext";s:15:"Free Membership";}";s:28:"arm_subscription_plan_amount";s:2:"75";s:28:"arm_subscription_plan_status";s:1:"1";s:26:"arm_subscription_plan_role";s:8:"armember";s:29:"arm_subscription_plan_post_id";s:1:"0";s:33:"arm_subscription_plan_gift_status";s:1:"0";s:31:"arm_subscription_plan_is_delete";s:1:"0";s:34:"arm_subscription_plan_created_date";s:19:"2021-10-05 17:46:30";s:31:"arm_user_selected_payment_cycle";s:1:"0";}s:14:"arm_start_plan";i:1663351412;s:15:"arm_expire_plan";s:0:"";s:17:"arm_is_trial_plan";i:0;s:15:"arm_trial_start";s:0:"";s:13:"arm_trial_end";s:0:"";s:16:"arm_payment_mode";s:19:"manual_subscription";s:17:"arm_payment_cycle";s:1:"0";s:20:"arm_is_user_in_grace";i:0;s:20:"arm_grace_period_end";s:0:"";s:23:"arm_grace_period_action";s:0:"";s:20:"arm_subscr_effective";s:0:"";s:18:"arm_change_plan_to";s:0:"";s:16:"arm_user_gateway";s:6:"manual";s:13:"arm_subscr_id";s:0:"";s:20:"arm_next_due_payment";s:10:"1694822400";s:23:"arm_completed_recurring";i:1;s:13:"arm_sent_msgs";s:0:"";s:18:"arm_cencelled_plan";s:0:"";s:17:"arm_authorize_net";a:0:{}s:13:"arm_2checkout";a:0:{}s:10:"arm_paypal";a:0:{}s:10:"arm_stripe";a:0:{}s:14:"payment_detail";a:0:{}s:21:"arm_started_plan_date";s:0:"";}