Convert into month name


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Convert into month name
# 1  
Old 10-06-2009
Convert into month name

Hi,

If I am having month like 2/3/4 then how can I convert it into month name like Feb/Mar/Apr....
Is there any defined function in Perl ??
# 2  
Old 10-06-2009
There is no pre-defined function for that, but it's easy to do yourself.
Code:
sub month_to_name {
    my @mons = qw/Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec/;
    my $month = shift;
    return $mons[$month - 1];
}

If you need something more complex, I found the Date::Calc module very useful.
# 3  
Old 10-06-2009
OK, thank you pludi !!

Will do it now by writting a function.. I was just curious if any inbuilt function is there in perl.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove new line and convert Month to Decimal

# Sample input common-name www.test.com.au expiration Dec 21 01:00:31 2017 GMT common-name www.test1.com.au expiration Jan 19 04:41:03 2018 GMT # Desired Output # Field 1: Domain name # Field 2: Date/time converted to Austraian format DD/MM/YYYY and on the same line as Domain Name. #... (7 Replies)
Discussion started by: thangbom
7 Replies

2. Shell Programming and Scripting

How to add decimal month to some month in sql, php, perl, bash, sh?

Hello, i`m looking for some way to add to some date an partial number of months, for example to 2015y 02m 27d + 2,54m i need to write this script in php or bash or sh or mysql or perl in normal time o unix time i`m asking or there are any simple way to add partial number of month to some... (14 Replies)
Discussion started by: bacarrdy
14 Replies

3. Shell Programming and Scripting

Convert From Month Number to Month Name

Hi, I have a script that accepts an input date from the user in yyyy-mm-dd format. I need to get the mm-dd part and convert it to month name. example: 2011-11-15 I want that to become "Nov 15" I don't have the GNU date, I am using an AIX os. Thanks. (1 Reply)
Discussion started by: erin00
1 Replies

4. UNIX for Advanced & Expert Users

Convert month(06) to String(Jun)

Hi All, From the below code i can see the value in M=05 and +1 added i.e 6. i am calling those 2 variables and the output is giving as 01-6-2013. But the required output should be 01-Jun-2013. Please let me know how can i get this format. M=$(date +%m) Y=$(date +%Y) if ; then ... (4 Replies)
Discussion started by: kiranparsha
4 Replies

5. Shell Programming and Scripting

How to convert date format such as 7/18/2015 to the number of month

How to convert date format such as 7/18/2015 to the number of month from requesting date 'date' in sh scripting ? Let say I have output in my log.txt -> 7/18/2015. How I convert it to the full number of month starting from 'date' till 7/18/2015 in shell scripting ? Thanks in advance. (1 Reply)
Discussion started by: amerabest
1 Replies

6. Shell Programming and Scripting

Script to counting a specific word in a logfile on each day of this month, last month etc

Hello All, I am trying to come up with a shell script to count a specific word in a logfile on each day of this month, last month and the month before. I need to produce this report and email it to customer. Any ideas would be appreciated! (5 Replies)
Discussion started by: pnara2
5 Replies

7. UNIX for Dummies Questions & Answers

print previous month (current month minus 1) with Solaris date and ksh

Hi folks month=`date +%m`gives current month Howto print previous month (current month minus 1) with Solaris date and ksh (7 Replies)
Discussion started by: slashdotweenie
7 Replies

8. AIX

Convert unix timestamp to year month day format ?

Hello, How do I convert unix timestamp value to 'normal' date format - to get year month and day values ? Looks like it's easy to do using GNU date (linux systems). But how do I do tthis on AIX ? I don't want to write C program, any ways to do that using unix shells ? thanks (1 Reply)
Discussion started by: vilius
1 Replies

9. Shell Programming and Scripting

How to convert DDMMYYYY to DD MONTH YYYY in Unix

Hi I am having date as a string in DDMMYYYY format(07082008) in a variable say cdate. I want to Convert it into DD Month YYYY format(7 August 2008). Could someone help. Thanks in Advance. (2 Replies)
Discussion started by: rspk_praveen
2 Replies

10. UNIX for Dummies Questions & Answers

To convert the numeric month into alphabetic

hi , This function actually gives me the last month but as a numeric value what should i do to get it as suppose :Jul date '+%b %Y' | { read MONTH YEAR MONTH=`expr "$MONTH" - 1` echo $MONTH } Thanks. Rooh (2 Replies)
Discussion started by: rooh
2 Replies
Login or Register to Ask a Question