Operating System - HP-UX
1821585 Members
3486 Online
109633 Solutions
New Discussion юеВ

Calculating date 45 days from now.

 
Dave Walley
Frequent Advisor

Calculating date 45 days from now.

Hi.

I need a create a script to calculate the date 45 days from now. Can anyone point me in the right direction. Is there a function to do this?

Any help greatly appreciated.

Thanking you.

Dave
why do i do this to myself
5 REPLIES 5
Patrick Wallek
Honored Contributor

Re: Calculating date 45 days from now.

There is a set of GNU utilities that you can pick up from the HP-UX porting and archive center. One of the utilities is a new 'date' command that will allow you to figure dates like you want. I currently use it and it works pretty well.

Here is the link to the package:

http://hpux.connect.org.uk/hppd/hpux/Gnu/sh_utils-2.0/
James R. Ferguson
Acclaimed Contributor

Re: Calculating date 45 days from now.

Dave:

This came up yesterday. The solution is in this thread:

http://forums.itrc.hp.com/cm/QuestionAnswer/1,1150,0x2fc2854994d9d4118fef0090279cd0f9,00.html

...JRF...
David DeMartini_1
New Member

Re: Calculating date 45 days from now.

There is a very simple way to do this and it was used on projects of HP and a big e-commerce house (in other words.. it works, it's simple and does not bloat the code).

Step1. Get the number or seconds from epoch. Date and other functions (what language are you using?) then add 3888000 to that, and convert back into 'human' form.

The number 3888000 is the number of seconds in a day (86400) times the number of days (45). No screwing around with calendars or anything like that. Works every time.

Party on, Garth.
Laziness is the father of invention.
Maureen Gunkel
Trusted Contributor

Re: Calculating date 45 days from now.

Dave,
I have an awk script I created just for this purpose, attached. The way I use it in a script is as follows:
echo 'mm/dd/yy/nn' | awk -f date_conv.awk
where nn is number of days to add (or -nn, subtract).
The output comes back as mm/dd/y.
Hope this helps,
Mo
No matter where you go, there you are.
Maureen Gunkel
Trusted Contributor

Re: Calculating date 45 days from now.

Dave,
I have an awk script I created just for this purpose, attached. The way I use it in a script is as follows:
echo 'mm/dd/yy/nn' | awk -f date_conv.awk
where nn is number of days to add (or -nn, subtract).
The output comes back as mm/dd/y.
Hope this helps,
Mo
No matter where you go, there you are.