Computing.Net > Forums > Unix > Unix current date minus 3 months

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Unix current date minus 3 months

Reply to Message Icon

Name: JGreenwood
Date: February 17, 2003 at 13:12:14 Pacific
OS: Windows NT
CPU/Ram: UNIX
Comment:

How do I calculate today's date minus 3 months? For example, I need this date (date +%D) which is 02/17/03 minus 3 months. So, my result that I want should be 11/17/02.
I am using ksh scripting.



Sponsored Link
Ads by Google

Response Number 1
Name: Nish
Date: February 17, 2003 at 20:55:39 Pacific
Reply:

Hope following URL will help you !http://www.computing.net/unix/wwwboard/forum/4559.html


0

Response Number 2
Name: Frank
Date: February 18, 2003 at 01:40:14 Pacific
Reply:

Hi,

typeset -i CuMonat
typeset -i Tag
typeset -i Jahr
typeset -i Monat

Tag=`date +%d`
Jahr=`date +%y`
CuMonat=`date +%m`

if [ $CuMonat -ge 4 ]
then
Monat=$CuMonat-3
else
Monat=$Cumonat+9
Jahr=$Jahr-1
fi

echo "${Monat}/${Tag}/${Jahr}"

Have Fun
Frank


0

Response Number 3
Name: Frank
Date: February 18, 2003 at 01:43:19 Pacific
Reply:

ups,

mistake,
use:
typeset -Z2 Tag
typeset -Z2 Jahr
typeset -Z2 Monat

Frank



0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Unix current date minus 3 months

How to get current date -1 hr www.computing.net/answers/unix/how-to-get-current-date-1-hr/4462.html

Display file date as a 3 digit day www.computing.net/answers/unix/display-file-date-as-a-3-digit-day/6610.html

UNIX/changing date format www.computing.net/answers/unix/unixchanging-date-format/8440.html