mysql - How can I add an implied year to a string which does not specify the year? -


i have download many text files website. have put mysql database, file has lines of form:

02/04 15:00 strings  03/03 15:00 other strings  01/12/2010 12:00 other strings  03/04 15:00 more strings  ... 

when year not explicitly written, means current year. need parse file line line , convert every date of form dd/mm date of form dd/mm/yyyy (where yyyy current year of course) before put database.
how can this?

awk -v year=$(date +%y) 'match($1, "^[0-9][0-9]/[0-9][0-9]$") {$1 = $1"/"year} 1'

or

awk -v year=$(date +%y) 'split($1, a, "/") == 2 {$1 = $1"/"year} 1'


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -