
update accept_order_details set validity_period=truncate(PERIOD_DIFF(DATE_FORMAT(ubd,"%y%m"), substring(lot_number,7,4))/6, 0) * 6 where product_set_id=17 and LENGTH(lot_number)=10 and ubd IS NOT NULL;
update order_details set validity_period=truncate(PERIOD_DIFF(DATE_FORMAT(ubd,"%y%m"), substring(lot_number,7,4))/6, 0) * 6 where product_set_id=17 and LENGTH(lot_number)=10 and ubd IS NOT NULL;
update purchase_details set validity_period=truncate(PERIOD_DIFF(DATE_FORMAT(ubd,"%y%m"), substring(lot_number,7,4))/6, 0) * 6 where product_set_id=17 and LENGTH(lot_number)=10 and ubd IS NOT NULL;
update sale_details set validity_period=truncate(PERIOD_DIFF(DATE_FORMAT(ubd,"%y%m"), substring(lot_number,7,4))/6, 0) * 6 where product_set_id=17 and LENGTH(lot_number)=10 and ubd IS NOT NULL;
update shipping_details set validity_period=truncate(PERIOD_DIFF(DATE_FORMAT(ubd,"%y%m"), substring(lot_number,7,4))/6, 0) * 6 where product_set_id=17 and LENGTH(lot_number)=10 and ubd IS NOT NULL;
update restoration_details set validity_period=truncate(PERIOD_DIFF(DATE_FORMAT(ubd,"%y%m"), substring(lot_number,7,4))/6, 0) * 6 where product_set_id=17 and LENGTH(lot_number)=10 and ubd IS NOT NULL;
update disposal_details set validity_period=truncate(PERIOD_DIFF(DATE_FORMAT(ubd,"%y%m"), substring(lot_number,7,4))/6, 0) * 6 where product_set_id=17 and LENGTH(lot_number)=10 and ubd IS NOT NULL;
update sample_details set validity_period=truncate(PERIOD_DIFF(DATE_FORMAT(ubd,"%y%m"), substring(lot_number,7,4))/6, 0) * 6 where product_set_id=17 and LENGTH(lot_number)=10 and ubd IS NOT NULL;
update adjustment_details set validity_period=truncate(PERIOD_DIFF(DATE_FORMAT(ubd,"%y%m"), substring(lot_number,7,4))/6, 0) * 6 where product_set_id=17 and LENGTH(lot_number)=10 and ubd IS NOT NULL;

update stocks set validity_period=truncate(PERIOD_DIFF(DATE_FORMAT(ubd,"%y%m"), substring(lot_number,7,4))/6, 0) * 6 where product_set_id=17 and LENGTH(lot_number)=10 and ubd IS NOT NULL;
