Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ksh date manipulation

1 view
Skip to first unread message

kevin_...@timeinc.com

unread,
Dec 11, 2000, 10:11:52 AM12/11/00
to
Hey all!

I need to do some date manipulation in ksh. For instance I need to get
yesterdays date. Can someone tell me how I can accomplish this? I have
looked through a couple of manuals and web pages, and can't seem to find
anything.
Please respond to kevin_...@timeinc.com as well as the group.
Thanks,
Kevin

kevin_...@timeinc.com

unread,
Dec 11, 2000, 11:53:57 AM12/11/00
to

hawk

unread,
Dec 12, 2000, 3:30:02 AM12/12/00
to
convert today's date to Julian date and then minus one from it to get
yesterday's date

man date - to find out more

<kevin_...@timeinc.com> wrote in message
news:3a350eb3$0$1...@wodc7nh6.news.uu.net...

Tristan Quaife

unread,
Dec 12, 2000, 4:30:39 AM12/12/00
to
kevin_...@timeinc.com wrote:
>
> Hey all!
>
> I need to do some date manipulation in ksh. For instance I need to get
> yesterdays date. Can someone tell me how I can accomplish this? I have
> looked through a couple of manuals and web pages, and can't seem to find
> anything.

Did you search through the comp.unix.shell archives too?

Depending on your version of date you can use:

date --d="yesterday"

to give yesterdays date.

Tristan.

Jeff Howie

unread,
Dec 17, 2000, 3:04:26 PM12/17/00
to kevin_...@timeinc.com, comp.un...@list.deja.com

A lot of people will recommend fiddling with the TZ settings, and a
equal # will advise aganst that. I use the GNU version of 'date' when
I possibly can. With it you can do funky things like:

$ date -d yesterday
$ date -d '2 days ago'
$ date -d '5 months 3 days' # in the future

If you don't already know, check out your version of date:

$ date --version

And if you already have it, check 'man date'.
--
thks.jeff


Sent via Deja.com http://www.deja.com/
Before you buy.

Clayton Hugo

unread,
Dec 20, 2000, 12:26:46 AM12/20/00
to
One way to do this, is to (temporarily) change your timezone variable to be
24 hours ago.. for instance: say your default timzone is GMT, then set
TZ=GMT+24 (you will get the idea).. then use the date command

-----------------------------------------------------------------
opinions are not of my employer, but of myself.
-----------------------------------------------------------------

0 new messages