Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2003
    Posts
    9

    Unanswered: Month value in SQL

    Hi all

    Does anyone know how to get the month field from a date in a SQL statement? I am using Oracle 8.0

    There is a field called "birth_date" in my table and I have to print the number of records group by month as follows:

    Month Count
    ------- -------
    1 45
    2 187
    3 18
    . ..
    . ..
    . ..
    etc

    I need the month value in 1-12 format. Please help..

    -Chinna

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    select month(birth_date),count(*)
    from yourtable
    group by month(birth_date)


    rudy

  3. #3
    Join Date
    Dec 2003
    Posts
    3
    There is not "month" function in Oracle!
    that shoulde be:
    select to_char(brith_day,'mm'),count(*) from yourtable group by to_char(brith_day,'mm')

  4. #4
    Join Date
    Dec 2003
    Posts
    74
    select to_char(sysdate,'MON') from dual;

    will return today's month

  5. #5
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    MONTH() is ANSI/ISO standard sql

    my apologies, Chinna, i overlooked the fact that you said oracle 8

    oracle corp, in its infinite wisdom, apparently did not begin supporting standard sql until release 9


Posting Permissions

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