The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

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 06:59 AM
yesterday date month/date skully Shell Programming and Scripting 5 06-24-2008 06:51 AM
last month end date vanathi UNIX for Advanced & Expert Users 7 03-21-2008 04:17 PM
find out month from a date rudoraj UNIX for Dummies Questions & Answers 5 07-03-2007 09:21 AM
how to get month last date in unix rajan_ka1 Shell Programming and Scripting 12 10-04-2005 08:20 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-15-2008
frustrated1 frustrated1 is offline
Registered User
  
 

Join Date: Aug 2003
Location: Ireland
Posts: 278
Get date one month from today

I need to get the date one month in the future from today - or 30 days from today etc...

I need this to work all year around - I cannot find anything to solve this issue in the search / faqs etc....
  #2 (permalink)  
Old 08-15-2008
frustrated1 frustrated1 is offline
Registered User
  
 

Join Date: Aug 2003
Location: Ireland
Posts: 278
Its okay - just found I can use something like the below


curmth=`date +%m`
set -A mth 01 02 03 04 05 06 07 08 09 10 11 12
nextmth=${mth[$((curmth))]}
echo $nextmth

curday=`date +%d`
curyear=`date +%Y`

todaynextmonth=$curyear$nextmth$curday
echo "todaynextmonth is $todaynextmonth"

Last edited by frustrated1; 08-15-2008 at 06:16 AM..
  #3 (permalink)  
Old 08-15-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
Your script doesn't work in December.

Did you actually look in the FAQ section? Yesterdays Date/Date Arithmetic
  #4 (permalink)  
Old 08-15-2008
vidyadhar85's Avatar
vidyadhar85 vidyadhar85 is offline Forum Staff  
Moderator(The Tutor)
  
 

Join Date: Jun 2008
Location: INDIA
Posts: 1,400
try this this will give you exact 30 days future date from todays date

fnsonlq0-/home/fnsonlq0>date
Fri Aug 15 15:44:59 IST 2008
fnsonlq0-/home/fnsonlq0>TZ=IST-720
fnsonlq0-/home/fnsonlq0>date
Sun Sep 14 10:15:06 IST 2008
fnsonlq0-/home/fnsonlq0>TZ=IST-5:30
fnsonlq0-/home/fnsonlq0>date
Fri Aug 15 15:45:11 IST 2008
  #5 (permalink)  
Old 08-15-2008
Lakris Lakris is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 246
Quote:
Originally Posted by frustrated1 View Post
I need to get the date one month in the future from today - or 30 days from today etc...

I need this to work all year around - I cannot find anything to solve this issue in the search / faqs etc....
Using the --date option lets You chose how You want it

date --date='1 month'
date --date='10 days ago'

/Lakris
  #6 (permalink)  
Old 08-15-2008
vidyadhar85's Avatar
vidyadhar85 vidyadhar85 is offline Forum Staff  
Moderator(The Tutor)
  
 

Join Date: Jun 2008
Location: INDIA
Posts: 1,400
hi Lakris i don't think all unix has that --date option
because AIX don't have any such option...
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 08:28 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