General
cancel
Showing results for 
Search instead for 
Did you mean: 

date 5 days from now formatted at %Y-%m-%d

SOLVED
Go to solution
John Meissner
Esteemed Contributor

date 5 days from now formatted at %Y-%m-%d

I accidently posted this in HP-UX... but it's on linux

Can anyone give a hand. I'm trying to get 5 days from now in this format
2003-10-08
i.e. %Y-%m-%d
i've used the commands
date -d "5 days next"
but it returns
Mon Oct 13 01:00:00 UTC 2003
anyone have a quick one liner (preferably without the use of caljd.sh)?
Any answer will be appreciated
All paths lead to destiny
9 REPLIES
John Meissner
Esteemed Contributor

Re: date 5 days from now formatted at %Y-%m-%d

Clay answered my question here:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=230058


Other answers are still welcome though
All paths lead to destiny
Alexander Chuzhoy
Honored Contributor

Re: date 5 days from now formatted at %Y-%m-%d

try:
date -s '+5 days next'
Alexander Chuzhoy
Honored Contributor

Re: date 5 days from now formatted at %Y-%m-%d

Sorry , this is not what you mean -zero points both please
John Meissner
Esteemed Contributor

Re: date 5 days from now formatted at %Y-%m-%d

sorry.. had to give you one for the honesty factor :)
All paths lead to destiny
Steven E. Protter
Exalted Contributor
Solution

Re: date 5 days from now formatted at %Y-%m-%d

I hae actually ported version 2.1 of of caljd.sh to Linux.

Not that it was a big deal, I just changed the shell at the top of the script.

I am attaching my version.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Stuart Browne
Honored Contributor

Re: date 5 days from now formatted at %Y-%m-%d

Well I'll stick with Pete Randall, GNU date is much more powerful:

date -d "5 days next" +"%Y-%m-%d"

is exactally what you want.

Enjoy.
One long-haired git at your service...
John Meissner
Esteemed Contributor

Re: date 5 days from now formatted at %Y-%m-%d

Stuart Browne -

That's perfect. Clay solved it from a different stand point (same result) on the HP forum. but that was much more simple....
my problem when i tried that was I typed:
date -d "5 days next" + "%Y-%m-%d"
instead of
date -d "5 days next" +"%Y-%m-%d"
(I had an extra space after the + sign)

thanks much!
All paths lead to destiny
Stuart Browne
Honored Contributor

Re: date 5 days from now formatted at %Y-%m-%d

Yea, I read what was said over there when you mentioned it. Clay and his perl-one-liners.. He's a damn god! ;P
One long-haired git at your service...
John Meissner
Esteemed Contributor

Re: date 5 days from now formatted at %Y-%m-%d

Yeah.... Clay is so good it's scary sometimes
All paths lead to destiny