문제

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'
도움이 되었습니까?

해결책

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"
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top