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 June 28th, 2006, 07:46 AM
UNIX Noob UNIX Noob is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2006
Posts: 1 UNIX Noob User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 3 sec
Reputation Power: 0
Another date conversion question

I'm new to the world of UNIX and scripting so please bear with me. Is there a built in function or a method to convert

07312006 to 31-Jul-06

I'm having a tough time trying to find a convert function for converting the numeric month to an abbr. month . Is there a way to do this without using a case statement? Thanks for you time!

Reply With Quote
  #2  
Old June 30th, 2006, 11:10 AM
jim mcnamara jim mcnamara is offline
......@.........
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jun 2004
Posts: 1,308 jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 5 h 17 m 10 sec
Reputation Power: 48
Using only shell:
Code:
#!/bin/ksh

num_to_month()
{
    set -A mnames Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
    typeset -i index="$1"
    index=index-1
    if [[ $index -lt 12 ]] ; then
        echo ${mnames[index]}
    else
        echo "Invalid month number"
    fi
}
num_to_month 01
num_to_month 02
num_to_month 03
num_to_month 04
num_to_month 05
num_to_month 06
num_to_month 07
num_to_month 08
num_to_month 09
num_to_month 10
num_to_month 11
num_to_month 12
num_to_month 13


Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > Another date conversion question


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 5 hosted by Hostway
Stay green...Green IT