Split a string into two parts

I have a string variable that which contains the date and and index number like “2015022401”. in this one, 20150224 is the date and 01 is the index. So i need to get these two values into separate two strings.
is there any function in my sql that i can do that?

I have the java code for this

            long last = 2015022402;
            String lastvalue = Long.toString(last);
            String datepart = lastvalue.substring(0, 8);
            String record = lastvalue.substring(8);
            long last_index = Long.parseLong(record);
            long last_ticket_date = (long)Long.parseLong(datepart);
              if(last_ticket_date==actual_date){
                ticketid = last+1;
              }else{
                generated_id=datev+"01";
                ticketid = Long.parseLong(generated_id);
              }

If you’re using MySQL substring exists for MySQL http://dev.mysql.com/doc/refman/5.7/en/string-functions.html#function_substr

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.