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
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
This code was posted here by someone else to determine yesterday:
#!/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,
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