UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 29th, 2004, 01:48 AM
SysAd_babe SysAd_babe is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Location: Philippines
Posts: 14 SysAd_babe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 22 sec
Reputation Power: 0
Red face increment month of date

I'm writing a shell script in unix about incrementing date. I want to increment the month of the current date whose format is `date +%b%Y`. So today the current date is May2004, i want the output to be Jun2004 and so if the current date is Dec2004, the output will be Jan2005. Need your advise asap. Thnx in advance.

Reply With Quote
  #2  
Old May 29th, 2004, 11:27 AM
mcq1 mcq1 is offline
mcq1
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Location: GA
Posts: 7 mcq1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
#!/bin/ksh

getNextMonth() {
aMonth=$(echo $1 | cut -c1-3); yr=$(echo $1 | cut -c4-)
months=$(cal $yr | grep "[A-Z][a-z][a-z]")

i=1; n=$(for mon in $months; do [[ "$mon" = "$aMonth" ]] && echo $i || (( i += 1 )); done)
[[ "$n" -eq 12 ]] && n=1 && (( yr += 1 )) || (( n += 1 ))
echo "$(echo $months | cut -d" " -f$n)$yr"
}
# test next month function ----------------------------------------------
for mmmdd in May2004 Dec2004 Jan2004 Mar2004 Aug2004 Dec2009
do
echo "in = $mmmdd \nout = $(getNextMonth $mmmdd)"
done

Reply With Quote
  #3  
Old May 29th, 2004, 09:01 PM
SysAd_babe SysAd_babe is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Location: Philippines
Posts: 14 SysAd_babe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 22 sec
Reputation Power: 0
Thumbs up Thanks ...

Thanks so much mcq1 for the script, it's now working. 'Til my next script problem ok, tc.

Reply With Quote
  #4  
Old July 7th, 2006, 04:48 AM
mann_naaz mann_naaz is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2006
Posts: 1 mann_naaz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 m 37 sec
Reputation Power: 0
Question Incrementing month or year in asp of userdefined date

how to increment month in asp can anybody help me???????
i m in big trouble.. plz!!!!!!!!!!

mn=month(fnsdt)
mn1=mn+1
or
directly i have done that increment but still it is not working,

bar="1"&"/"&Monthname(month(fnsdt)+1)&"/"&year(fnsdt)

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > increment month of date


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT