The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Help, I need to get the last date of previous month sirrtuan Shell Programming and Scripting 10 06-16-2008 12:01 PM
KSH Checking Previous Date** developncode UNIX for Dummies Questions & Answers 4 04-17-2008 09:42 AM
date issue-find prevoius date in a patricular format bsandeep_80 UNIX for Advanced & Expert Users 3 11-15-2007 04:42 PM
Specify a previous date as start date in shell script ritzwan0 Shell Programming and Scripting 2 09-25-2006 02:58 PM
Get the Previous date Nayanajith Shell Programming and Scripting 2 06-28-2006 10:39 PM

Closed Thread
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-21-2001
Registered User
 

Join Date: Apr 2001
Posts: 17
Stumble this Post!
Unhappy

Hi All,
How to find a date which is 7 days from the current date as well as how to find a date which is 7 days before this current date.

Urgently i need help.

Thanks in Advance

Regards

Arunava
Forum Sponsor
  #2 (permalink)  
Old 05-22-2001
Registered User
 

Join Date: Dec 2000
Location: Greater Dallas area
Posts: 405
Stumble this Post!
This code was posted here by someone else to determine yesterday:
Code:
#!/usr/bin/ksh
date '+%m %d %Y' | 
{ 
read MONTH DAY YEAR
DAY=`expr "$DAY" - 1` 
case "$DAY" in 
        0) 
           MONTH=`expr "$MONTH" - 1` 
                case "$MONTH" in 
                        0) 
                           MONTH=12 
                           YEAR=`expr "$YEAR" - 1` 
                        ;; 
                esac 
        DAY=`cal $MONTH $YEAR | grep . | fmt -1 | tail -1` 
esac 
echo "Yesterday was: $MONTH $DAY $YEAR" 
}
It can probably be modified to do what you ask,
__________________
[url=http://chuckb.1le.net/]My website[/url]
  #3 (permalink)  
Old 05-24-2001
mib mib is offline
Registered User
 

Join Date: Jan 2001
Location: Calicut
Posts: 228
Stumble this Post!
or use perl method:

print scalar localtime (time() - 86400 * n);
it will substract n from current date and print the date

To get date seven days from now:
print scalar localtime (time() + 86400 * 7);

7 days before current date:
print scalar localtime (time() - 86400 * 7);



HTH
Google The UNIX and Linux Forums
Closed Thread

Thread Tools
Display Modes




All times are GMT -7. The time now is 03:54 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0