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

Date function

1 view
Skip to first unread message

Diego Balgera

unread,
Jan 29, 2004, 6:04:10 AM1/29/04
to
Hi,

could you please suggest a method to add and subtract a certain number of
days to a date in Unix, i.e. the date returned by the "date" command?

Thank you in advance.

Br.
Diego.


Stephane CHAZELAS

unread,
Jan 29, 2004, 6:22:57 AM1/29/04
to
2004-01-29, 11:04(+00), Diego Balgera:

> could you please suggest a method to add and subtract a certain number of
> days to a date in Unix, i.e. the date returned by the "date" command?

RTFFAQ.

--
Stéphane ["Stephane.Chazelas" at "free.fr"]

Vallo Kallaste

unread,
Jan 29, 2004, 8:01:38 AM1/29/04
to
Diego Balgera <x.nospam.diego....@nokia.com> wrote:

> could you please suggest a method to add and subtract a certain number of
> days to a date in Unix, i.e. the date returned by the "date" command?

At least FreeBSD date(1) has -v switch for it, i.e.
'date -v +1d` will produce output with date adjusted one day to the
future. The recent versions of ksh93 have also quite good datetime
handling capabilities, i.e.
'printf "%T\n" "exactly tomorrow"` will produce the same output as
previous, excepting the locale issues.
--
Vallo Kallaste

Stephane CHAZELAS

unread,
Jan 29, 2004, 9:10:22 AM1/29/04
to
2004-01-29, 15:01(+02), Vallo Kallaste:
[...]

> The recent versions of ksh93 have also quite good datetime
> handling capabilities, i.e.
> 'printf "%T\n" "exactly tomorrow"` will produce the same output as
> previous, excepting the locale issues.

Where is that documented? "printf --man" speaks of "%T", but
there's no specification for either the date/time syntax nor the
format.

I can see some indications in the source code for the "format"
in the "usage" variable in src/lib/libcmd/date.c (sort of
strftime-like not compatible with SUSv3 strftime, but with
interesting extensions).

I couldn't find anywhere information about "exactly tomorrow".
There's also src/lib/libast/man/tm.3, but it's not of much help.

j...@invalid.address

unread,
Jan 29, 2004, 3:05:44 PM1/29/04
to
"Diego Balgera" <x.nospam.diego....@nokia.com> writes:

> could you please suggest a method to add and subtract a certain
> number of days to a date in Unix, i.e. the date returned by the
> "date" command?

There's a section in the FAQ about this:

http://home.comcast.net/~j.p.h/cus-faq.html#G

Joe
--
I think people should be able to make up their own minds for me
- Monty Python

Diego Balgera

unread,
Jan 30, 2004, 5:53:47 AM1/30/04
to
Hi,
I forgot to specify that my environment is Hp Hp-ux 11.0.
D.

"Diego Balgera" <x.nospam.diego....@nokia.com> wrote in message
news:KM5Sb.7924$k4.1...@news1.nokia.com...

Stephane CHAZELAS

unread,
Jan 30, 2004, 6:19:54 AM1/30/04
to
2004-01-30, 10:53(+00), Diego Balgera:

> Hi,
> I forgot to specify that my environment is Hp Hp-ux 11.0.
> D.

So, what about Reading The Fine FAQ and telling us why the
responses there don't suit your needs?

http://home.comcast.net/~j.p.h/cus-faq.html
http://www.faqs.org/faqs/by-newsgroup/comp/comp.unix.shell.html

http://groups.google.com/groups?q=wide_strftime&scoring=d

Diego Balgera

unread,
Feb 3, 2004, 9:06:38 AM2/3/04
to
Hi,
thank you to everyone for your valuable suggestions.

As you suggested, I found the solution of my problem here:

http://groups.google.com/groups?q=wide_strftime&hl=en&lr=&ie=UTF-8&scoring=d&selm=slrnbrfohk.49.stephane.chazelas%40spam.is.invalid&rnum=2

and in the excellent caljd.sh tool (thanks to A. Clay Stephenson).

Thank you again.
D.


"Diego Balgera" <x.nospam.diego....@nokia.com> wrote in message
news:KM5Sb.7924$k4.1...@news1.nokia.com...

0 new messages