Monday, November 4, 2013

Date Format Using Gawk Script

www.unixbabuforum.innee sample script to cover the mmddyy to ccyy-mm-dd using gawk scipt 

for eg: input file has value in the colum 010198 and this should conver to 19980101

www.unixbabuforum.inTry:
function dtYmd (t, Local, y, m, d, c) {
??? y = substr (t, 5, 2);
??? m = substr (t, 3, 2);
??? d = substr (t, 1, 2);
??? c = (y >= 50) ? 19 : 20;
??? return (sprintf ("%.2d%.2d%.2d%.2d", c, y, m, d));
}

And you would call it inline for a specific field like:

{ $7 = dtYmd( $7);


0 comments:

Post a Comment

 
Design by BABU | Dedicated to grandfather | welcome to BABU-UNIX-FORUM