- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Date variable minus 60 days - how to calculate?
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-26-2000 02:34 PM
тАО10-26-2000 02:34 PM
Anyhoo, I'm trying to manipulate the date a user inputs while running a shell script to subtract 60 days from it. I have a VERY klutzy way of doing it, but my way won't work with months <> 30 days (approx. half of them!). I don't know C or Perl, and am tring to do this in C-shell, perhaps with awk?
Thanks to anyone who can help!!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-26-2000 02:55 PM
тАО10-26-2000 02:55 PM
Re: Date variable minus 60 days - how to calculate?
Try to following url to get the bundle of utilities: http://www.gnu.org/gnulist/production/shellutils.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-26-2000 03:00 PM
тАО10-26-2000 03:00 PM
Re: Date variable minus 60 days - how to calculate?
http://hpux.cae.wisc.edu/hppd/hpux/Gnu/sh_utils-2.0/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-26-2000 03:45 PM
тАО10-26-2000 03:45 PM
Re: Date variable minus 60 days - how to calculate?
Here is the URL which talks about date comparisons using perl.
http://webmaster.indiana.edu/perl56/pod/perlfaq4.html#data:%20dates
Hope this helps.
......Madhu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-26-2000 04:31 PM
тАО10-26-2000 04:31 PM
Re: Date variable minus 60 days - how to calculate?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-26-2000 05:57 PM
тАО10-26-2000 05:57 PM
Solutionread curdate
olddate=`echo $curdate | awk -f whatever.awk`
Hope this helps.
***************************************
BEGIN{ FS="/"
split( "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec", month," ");
split( "31 28 31 30 31 30 31 31 30 31 30 31", days, " ");
}
{
year = $3
leapyear = year % 4;
if( leapyear == 0 )
days[2] = 29
else
days[2] = 28;
doy = 0;
for ( i = 1; i< $1; i++ )
doy = doy + days[i]
doy = doy + $2;
if ( doy <= 60 )
{
doy = doy + 365;
year = year - 1;
leapyear = year %4;
if( leapyear == 0 )
{
days[2] = 29;
doy = doy + 1;
}
}
doy = doy - 60;
for ( i = 1; i <= 12; i++ )
{
doy = doy - days[i];
if ( doy <= 0 )
{
doy = doy + days[i];
break;
}
}
printf( "%d/%d/%dn", i, doy, year )
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-27-2000 01:42 AM
тАО10-27-2000 01:42 AM
Re: Date variable minus 60 days - how to calculate?
Of course, one could also use the ctime() standard C func and Co., maybe slightly less comfortably though.
I'm not particularily fond of the C-shell and thus didn't care much of what the C-shell has to offer in this respect.
What is the date format read as user input from your script (because it seems more of a formatting issue)?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-27-2000 07:28 AM
тАО10-27-2000 07:28 AM
Re: Date variable minus 60 days - how to calculate?
Bee-yoo-ti-ful! I have a slight problem with the format of the date returned, but I can fix that. You've saved my bacon! Thanks again!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-27-2000 12:25 PM
тАО10-27-2000 12:25 PM
Re: Date variable minus 60 days - how to calculate?
You might want to change the printf format in order to print leading 0's or not.