mysql - Add 28 to last 2 digit of date and replace the order -
i have number such : 840106
i need following :
- change number date add - , flip number : 06-01-84
 - 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
Post a Comment