Frage

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'
War es hilfreich?

Lösung

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"
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top