I have this code:
SET @startEndTimeCapacity = "'00:00:00', '08:00:00', 120";
SELECT SUBSTRING_INDEX(@startEndTimeCapacity, ",", 2);
results in '00:00:00', '08:00:00'.
How can I get the 2nd value '08:00:00' only?
I have this code:
SET @startEndTimeCapacity = "'00:00:00', '08:00:00', 120";
SELECT SUBSTRING_INDEX(@startEndTimeCapacity, ",", 2);
results in '00:00:00', '08:00:00'.
How can I get the 2nd value '08:00:00' only?
You can apply the SUBSTRING_INDEX function twice:
Here's how:
SUBSTRING_INDEX(SUBSTRING_INDEX(@startEndTimeCapacity, ",", 2), ',', -1);
This works for any n. In this specific case n=2.