Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2003
    Posts
    51

    Unanswered: Display Month in words and numbers

    From the current month , i want to display its previous month and next month, in words as well as in numbers.
    How can i do it.

    If curmonth=Dec.
    prev month in words=Nov
    prev month in number=11
    next month in words=Jan
    next month in number=1

    Thanks.
    sampath gowri

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    Dec 2004
    Location
    Memphis
    Posts
    25

    Post

    Quote Originally Posted by sampathgowri
    From the current month , i want to display its previous month and next month, in words as well as in numbers.
    How can i do it.

    If curmonth=Dec.
    prev month in words=Nov
    prev month in number=11
    next month in words=Jan
    next month in number=1

    Thanks.
    Hi !

    The following query would show the Previous, Next Month in Words:

    Select To_char(Sysdate,'Mon') As "Month", To_char(Sysdate-27,'Mon') As "Prev", To_char(Sysdate+27,'Mon') As "Next" from dual;

    The following query would show the Previous, Next Month in Number:

    Select To_char(Sysdate,'MM') As "Month", To_char(Sysdate-27,'MM') As "Prev", To_char(Sysdate+27,'MM') As "Next" from dual;
    NewKid

    A Newkid in the block

  4. #4
    Join Date
    Nov 2002
    Location
    Desk, slightly south of keyboard
    Posts
    697
    Quote Originally Posted by kidkid
    Hi !
    Select To_char(Sysdate,'Mon') As "Month", To_char(Sysdate-27,'Mon') As "Prev", To_char(Sysdate+27,'Mon') As "Next" from dual;
    Some months can have more than 27 days which makes your code unreliable (Sysdate of 1st of December for example would return December as next).

    Use the Oracle supplier ADD_MONTHS() function

    Code:
    select to_char( sysdate, 'MON' ) as month,
           to_char( add_months( sysdate,1 ), 'MON' ) as next, 
           to_char( add_months( sysdate,-1 ), 'MON' ) as prev 
    from dual
    Hth
    Bill
    Please don't email me directly with questions. I've probably just got home from the pub and cannot guarantee the sanity of my answers. In fact, I can't believe I actually made it home.

  5. #5
    Join Date
    Dec 2004
    Location
    Memphis
    Posts
    25

    Thanks Bill !

    Thanks Bill for correcting my answer !
    NewKid

    A Newkid in the block

  6. #6
    Join Date
    Oct 2003
    Posts
    51
    Thank you all of you.
    sampath gowri

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •