![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| 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 !! |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
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 | ||
|
|
|
|||
|
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"
}
__________________
[url=http://chuckb.1le.net/]My website[/url] |
|
|||
|
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 |