Domanda

Looked for it for hours and nothing worked. Would really much appreciate any answer.

initial_date (format %m%d%Y) holds a value returned by an oracle database query. I want to increment this date with 1 day and use it further as an input parameter for some functions.

> echo $initial_date
02012014 

>tomorrow_date=`date +"%m%d%Y" -d ${initial_date}' + 1 day'`
date: invalid date `02012014 + 1 day'
È stato utile?

Soluzione

You need to convert the initial date to a valid format, such as yyyyMMdd first. Try:

date +"%m%d%Y" -d "${initial_date:4}${initial_date:0:4} + 1 day"
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top