The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 11 10-14-2008 05:59 AM
KSH Checking Previous Date** developncode UNIX for Dummies Questions & Answers 4 04-17-2008 12:42 PM
date issue-find prevoius date in a patricular format bsandeep_80 UNIX for Advanced & Expert Users 3 11-15-2007 08:42 PM
Specify a previous date as start date in shell script ritzwan0 Shell Programming and Scripting 2 09-25-2006 05:58 PM
Get the Previous date Nayanajith Shell Programming and Scripting 2 06-29-2006 01:39 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-21-2001
arunava_maity arunava_maity is offline
Registered User
  
 

Join Date: Apr 2001
Posts: 17
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
  #2 (permalink)  
Old 05-22-2001
98_1LE 98_1LE is offline Forum Advisor  
Registered User
  
 

Join Date: Dec 2000
Location: Greater Dallas area
Posts: 405
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,
  #3 (permalink)  
Old 05-24-2001
mib mib is offline
Registered User
  
 

Join Date: Jan 2001
Location: Calicut
Posts: 228
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
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:59 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0