Home » SQL & PL/SQL » SQL & PL/SQL » Problem in converting Month to month numbers?
Problem in converting Month to month numbers? [message #323641] Thu, 29 May 2008 02:09 Go to next message
tondapi
Messages: 99
Registered: August 2007
Location: usa
Member
Hi,

I have one problem,i want help from your side.

The problem is,in my database i have month and list of values of this month is Jan,Feb,May.....But user want to convert this one in to numbers means Jan--01,Feb---02...etc.How can i do converstion.Plz help me.
Re: Problem in converting Month to month numbers? [message #323645 is a reply to message #323641] Thu, 29 May 2008 02:18 Go to previous messageGo to next message
Littlefoot
Messages: 20897
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
DECODE might be one way to do that.
Re: Problem in converting Month to month numbers? [message #323649 is a reply to message #323645] Thu, 29 May 2008 02:28 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
You could try something like this:
to_char(to_date('JAN','MON'),'MM')
Re: Problem in converting Month to month numbers? [message #323654 is a reply to message #323649] Thu, 29 May 2008 02:50 Go to previous message
Michel Cadot
Messages: 64122
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Don't forget to precise the language you have for your month name:
SQL> select to_char(to_date('JAN','MON'),'MM') from dual;
select to_char(to_date('JAN','MON'),'MM') from dual
                       *
ERROR at line 1:
ORA-01843: not a valid month


SQL> select to_char(to_date('JAN','MON','NLS_DATE_LANGUAGE=ENGLISH'),'MM') from dual;
TO
--
01

1 row selected.

Regards
Michel
Previous Topic: validation check for numeric and alphabets
Next Topic: BULK COLLECT problem
Goto Forum:
  


Current Time: Wed Dec 07 04:52:37 CST 2016

Total time taken to generate the page: 0.08893 seconds