mysql - Add 28 to last 2 digit of date and replace the order -


i have number such : 840106

i need following :

  1. change number date add - , flip number : 06-01-84
  2. add 28 last 2 digit date : 06-01-12

84 + 16 = 00 + 12 = 12

number changing cab 850617 , format same add - , add 28 last 2 digit.

any ideas how me here ?

here sqlite solution:

create table t( c text);  insert t (c) values(990831); insert t (c) values(840106); insert t (c) values(800315); insert t (c) values(750527); insert t (c) values(700923); insert t (c) values(620308);  select c, substr(c,5,2) || '-' || substr(c,3,2) || '-' ||    case when (substr(c,1,2) + 28) < 100 (substr(c,1,2) + 28)         else case when ((substr(c,1,2) + 28) - 100) < 10 '0' || ((substr(c,1,2) + 28) - 100)           else ((substr(c,1,2) + 28) - 100)          end   end t; 

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -