Get month from a date column ina table

Hi
I have a table that consists of one column of date data type. For example it stores mm/dd/yyyy.
I want to get all the records from this table where month = 12. for the year 2000.
I saw the extract function. However That is used while selecting. How can I give a condition in where clause:
select date_col
from dates-table
where <get month for date_col> = december or 12
and year = 2000???

Ok that certainy helps.
This is what I am trying to do.
I have a procedure to which I am passing the date_param (of date data type).
declare
my_month date;
begin
select to_char(date_param,'MM') into my_month from dual;
select date_col from dates-table where to_char(date_col,'mm')= my_month and some_indicator='Y';
end;This will return me one date where the indicator is set to Y.
For example date_param is passed as 01/01/2000.
select to_char('01/01/2000','MM') from dual;I get the error when I run the above. I get an error saying invalid number.

Similar Messages

  • Get the month from a date column with the calculated column

    I am trying to get the month from a date field with the help of calculated column. However I get this syntax error whenever I want to submit the formula:
    Error 
    The formula contains a syntax error or is not supported. 
    the default language of our site is German and [datum, von] is a date field.

    Hi,
    I have created two columns
    Current MM-YY
    Calculated (calculation based on other columns)
    Today
    Date and Time
    Current MM-YY is calculated value with formula as
    =TEXT(Today,"mmmm")
    But the output shows as December instead of May.
    I have tried =TEXT([Datum, von];"mmmm") but no help.
    I am trying to populated the column automatically with current month..ex: if its May the field should show May, next month it should show June an so on.
    Any kind help is grateful.
    Regards,
    Pradeep

  • Get months from a date range comparing event date

    Hi All,
    Below is the data
    CREATE TABLE #Coverage(
    EmployeeID INT,
    EmployeeName VARCHAR(20),
    CoverageName VARCHAR(50),
    CoverageAmount Decimal,
    CoveredBy VARCHAR(20),
    EventDate DATETIME,
    CoverageStartDate DATETIME,
    CoverageEndDate DATETIME
    INSERT INTO #coverage VALUES (8,'Lara','Employee + Children',213.60,'EmployeeContribution','2013-10-01','2013-10-01','2014-05-31'),
    (8,'LAra','Employee + Children', 606.31 ,'CompanyContribution' ,'2013-10-01','2013-10-01','2014-05-31'),
    (8,'LAra','Employee Only' ,0.00 ,'EmployeeContribution' ,NULL ,'2013-06-01','2014-05-31'),
    (8,'LAra','Employee Only' ,431.55 ,'CompanyContribution' ,NULL ,'2013-06-01','2014-05-31'),
    (8,'LAra','Employee Only' ,81.42 ,'EmployeeContribution' ,NULL ,'2012-06-01','2013-05-31'),
    (8,'LAra','Employee Only' ,420.93 ,'CompanyContribution' ,NULL ,'2012-06-01','2013-05-31')
    SELECT * FROM #Coverage
    drop table #coverage
    and expected out put for the year 2013
    EmployeeID
    EmployeeName
    CoverageName
    CoverageAmount
    CoveredBy
    Month
    Year
    8
    Lara
    Employee Only
    81
    Employee Contibution
    1
    2013
    8
    Lara
    Employee Only
    421
    Company Contribution
    1
    2013
    8
    Lara
    Employee Only
    81
    Employee Contibution
    2
    2013
    8
    Lara
    Employee Only
    421
    Company Contribution
    2
    2013
    8
    Lara
    Employee Only
    81
    Employee Contibution
    3
    2013
    8
    Lara
    Employee Only
    421
    Company Contribution
    3
    2013
    8
    Lara
    Employee Only
    81
    Employee Contibution
    4
    2013
    8
    Lara
    Employee Only
    421
    Company Contribution
    4
    2013
    8
    Lara
    Employee Only
    81
    Employee Contibution
    5
    2013
    8
    Lara
    Employee Only
    421
    Company Contribution
    5
    2013
    8
    Lara
    Employee Only
    81
    Employee Contibution
    6
    2013
    8
    Lara
    Employee Only
    421
    Company Contribution
    6
    2013
    8
    Lara
    Employee Only
    81
    Employee Contibution
    7
    2013
    8
    Lara
    Employee Only
    421
    Company Contribution
    7
    2013
    8
    Lara
    Employee Only
    81
    Employee Contibution
    8
    2013
    8
    Lara
    Employee Only
    421
    Company Contribution
    8
    2013
    8
    Lara
    Employee Only
    81
    Employee Contibution
    9
    2013
    8
    Lara
    Employee Only
    421
    Company Contribution
    9
    2013
    8
    Lara
    Employee +Children
    214
    Employee Contibution
    10
    2013
    8
    Lara
    Employee +Children
    606
    Company Contribution
    10
    2013
    8
    Lara
    Employee +Children
    214
    Employee Contibution
    11
    2013
    8
    Lara
    Employee +Children
    606
    Company Contribution
    11
    2013
    8
    Lara
    Employee +Children
    214
    Employee Contibution
    12
    2013
    8
    Lara
    Employee +Children
    606
    Company Contribution
    12
    2013
    Can any one help me out with this.
    Thanks!

    This gives your resultset.
    I've added the cte to give a newenddate because your dataset doesn't close off the previous one in all cases and gave duplicates - you can remove this if it is a mistake in the data. Also you would need to add the employee to the partition to run on multiple
    employees.
    declare
    @Coverage TABLE (
    EmployeeID
    INT,
    EmployeeName
    VARCHAR(20),
    CoverageName
    VARCHAR(50),
    CoverageAmount
    Decimal,
    CoveredBy
    VARCHAR(20),
    EventDate
    DATETIME,
    CoverageStartDate
    DATETIME,
    CoverageEndDate
    DATETIME
    INSERT
    INTO @Coverage
    VALUES (8,'Lara','Employee + Children',213.60,'EmployeeContribution','2013-10-01','2013-10-01','2014-05-31'),
    (8,'LAra','Employee
    + Children',  606.31
    ,'CompanyContribution'    
    ,'2013-10-01','2013-10-01','2014-05-31'),
    (8,'LAra','Employee
    Only'               
    ,0.00  ,'EmployeeContribution'   
    ,NULL  ,'2013-06-01','2014-05-31'),
    (8,'LAra','Employee
    Only'               
    ,431.55      
    ,'CompanyContribution'    
    ,NULL  ,'2013-06-01','2014-05-31'),
    (8,'LAra','Employee
    Only'               
    ,81.42 ,'EmployeeContribution'   
    ,NULL  ,'2012-06-01','2013-05-31'),
    (8,'LAra','Employee
    Only'               
    ,420.93      
    ,'CompanyContribution'    
    ,NULL  ,'2012-06-01','2013-05-31')
    SELECT
    * FROM
    @Coverage
    ;with
    ctee1 as
    select
    *, seq
    = row_number()
    over (partition
    by coveredby
    order by coveragestartdate)
    from
    @Coverage
    ,ctee
    as
    select
    c1.*,
    newenddte = coalesce(c2.coveragestartdate-1,
    c1.coverageenddate)
    from
    ctee1 c1
    left
    join ctee1
    c2
    on
    c1.coveredby
    = c2.coveredby
    and
    c1.seq
    = c2.seq-1
    cte1 as
    select
    dtestrt =
    convert(datetime,'20130101'),
    dteend =
    convert(datetime,'20131201')
    ,cte
    as
    select
    dtestrt =
    cte1.dtestrt,
    dteend =
    dateadd(mm,1,cte1.dtestrt)-1,
    mth =
    month(cte1.dtestrt),
    yr =
    year(cte1.dtestrt)
    from cte1
    union
    all
    select
    dtestrt =
    dateadd(mm,1,cte.dtestrt),
    dteend =
    dateadd(mm,2,cte.dtestrt)-1,
    mth =
    month(dateadd(mm,1,cte.dtestrt)),
    yr =
    year(dateadd(mm,1,cte.dtestrt))
    from cte,
    cte1 where
    cte.dtestrt
    < cte1.dteend-1
    select
    c.EmployeeID,
    c.EmployeeName,
    c.CoverageName,
    c.CoverageAmount,
    c.CoveredBy,
    cte.mth,
    cte.yr,
    cte.dtestrt,
    cte.dteend
    from
    cte
    join
    ctee c
    on
    cte.dtestrt
    <= c.newenddte 
    and cte.dteend
    >= c.CoverageStartDate
    order
    by c.EmployeeID,
    cte.dtestrt

  • How to get name of the month from current date.

    Hi,
       How to get the name of the month from current date.
    Thanks,
    Senthil

    Sethil,
    Use your date(let us say Date1) instead of sy-datum.
    CALL FUNCTION 'MONTH_NAMES_GET'
    EXPORTING
    LANGUAGE = SY-LANGU
    IMPORTING
    RETURN_CODE =
    TABLES
    MONTH_NAMES = itab_month
    EXCEPTIONS
    MONTH_NAMES_NOT_FOUND = 1
    OTHERS = 2
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    READ TABLE itab_month
    WITH KEY MNR = date1+4(2).
    itab_month-LTX will contain the value you are looking for
    Good luck
    Raghava

  • Get month from date

    I want to get the month from a date. I know how I can get it from today's date, but let's say I have a pre-defined date like:
    String myDate = "11/15/89";How can I get "November" from that?
    Edited by: TheTitans on Feb 12, 2009 4:56 PM

    SimpleDateFormat[http://java.sun.com/docs/books/tutorial/i18n/format/simpleDateFormat.html]
    ~

  • Get last august month from current date

    Hi,
    I need to get last august month from current date.
    e.g if current date is 1-OCT-2013 need to get last August date i.e.1-AUG-2013
    e.g. if current date is 1-MAY-2013 need to get last August date i.e.1-AUG-2012

    Something like this?
    SQL> WITH table_x AS(
      2     SELECT SYSDATE dt from dual UNION ALL
      3     SELECT TO_DATE('20-05-2013','dd-mm-yyyy') from dual
      4  )
      5  --
      6  ---
      7  --
      8  SELECT  dt,
      9    CASE
    10      WHEN (dt >= Add_Months(TRUNC(dt,'YEAR'),7)) THEN
    11          Add_Months(TRUNC(dt,'YEAR'),7)
    12      WHEN (dt < Add_Months(TRUNC(dt,'YEAR'),7)) THEN
    13          Add_Months(TRUNC(dt,'YEAR'),7) - 365
    14    END cs
    15  FROM table_x;
    DT        CS
    24-OCT-13 01-AUG-13
    20-MAY-13 01-AUG-12

  • Getting month from Calendar Year/month...

    Dear All,
    I'm using Webi 4.0 SP6 and I need to get months from Calendar Year/Month which I'm using in a query to display on Cross Table along with brands.
    1. Is there any standard function available to convert Calandar Year/Month (Say: 201401 to Jan or January).?
    2. How can I get month from Calendar Year/Month for cross-table?
    I will appreciate your reply.
    Many Thanks!!!
    Tariq Ashraf

    Tariq,
    Month =  Substr([Cal Year];5;2)
    Month Name = If Substr([Cal Year];5;2) = "01" then "Jan"
                             else if Substr([Cal Year];5;2) = "02" then "Feb"
                             else if Substr([Cal Year];5;2) = "03" then "Mar"
                             else if Substr([Cal Year];5;2) = "04" then  "Apr"
                             else if Substr([Cal Year];5;2) = "05" then  "May"
                             else if Substr([Cal Year];5;2) = "06" then  "Jun"
                             else if Substr([Cal Year];5;2) = "07" then   "Jul"
                             else if Substr([Cal Year];5;2) = "08" then  "Aug"
                             else if Substr([Cal Year];5;2) = "09" then   "Sep"
                             else if Substr([Cal Year];5;2) = "10" then   "Oct"
                             else if Substr([Cal Year];5;2) = "11" then  "Nov" else "Dec"
    If you have data like 20140101 then simply use = formatdate([Date];"Mon")

  • Get value from  APEX_ITEM.SELECT_LIST_FROM_QUERY - column on a report.

    Hello.
    Help. Help. Help.
    I have to get value from APEX_ITEM.SELECT_LIST_FROM_QUERY - column on a report.
    SELECT DISTINCT ROLE AS GET_ROLE,
    JOB AS GET_JOB,
    APEX_ITEM.SELECT_LIST_FROM_QUERY
    ( 1, '%', 'SELECT DISTINCT CODE c,
    MODE m
    FROM T2
    WHERE ROLE = ' || ROLE ) AS GET_CODE
    FROM T1
    WHERE AGE >30 AND
    SEX = 'M' ;
    I was trying to use javascript :
    for (var i = 0; i < selectlist_name.options.length; i++)
    if (selectlist_name.options[ i ].selected)
    result=selectlist_name.options;
    But I don't know is that correct:
    "selectlist_name" - APEX_ITEM.F01
    (of my APEX_ITEM.SELECT_LIST_FROM_QUERY)?

    Just as a note, but you want to make sure your APEX_ITEM call is closed. The code snippet you posted isn't complete.
    APEX_ITEM.SELECT_LIST_FROM_QUERY(6,c020, 'select DISTRIBUTION_NAME, DISTRIBUTION_NAME from DISTRIBUTIONS','style="", SEQ_ID   <-- No closing )In the documentation - http://www.utoug.org/i/doc/api099.htm - (though it isn't necessarily the easiest to read) it gives this explanation of the syntax:
    APEX_ITEM.SELECT_LIST_FROM_QUERY(
    p_idx IN NUMBER,
    p_value IN VARCHAR2 DEFAULT,
    p_query IN VARCHAR2,
    p_attributes IN VARCHAR2 DEFAULT,
    p_show_null IN VARCHAR2 DEFAULT,
    p_null_value IN VARCHAR2 DEFAULT,
    p_null_text IN VARCHAR2 DEFAULT,
    p_item_id IN VARCHAR2 DEFAULT,
    p_item_label IN VARCHAR2 DEFAULT,
    p_show_extra IN VARCHAR2 DEFAULT)
    RETURN VARCHAR2;
    What you want to look at is p_value to set an initial value. It should come from your data, but you could consider doing an NVL or DECODE to substitute your default.
    In this case it would modify your query to be:
    SELECT distinct apex_item.hidden(1, seq_id), c003,c004,c005, c006,
          APEX_ITEM.SELECT_LIST_FROM_QUERY(6,c020, 'select DISTRIBUTION_NAME, DISTRIBUTION_NAME from DISTRIBUTIONS','style=""),
          SEQ_ID
      FROM APEX_collections
    WHERE collection_name = 'ARGYLL_INVOICES'
    order by seq_id If the value is always NULL, you can use the p_show_null, p_null_value, and p_null_text to put in a "default"
    SELECT distinct apex_item.hidden(1, seq_id), c003,c004,c005, c006,
          APEX_ITEM.SELECT_LIST_FROM_QUERY(6,NVL(c020,0), 'select DISTRIBUTION_NAME, DISTRIBUTION_NAME from DISTRIBUTIONS','style="",YES, 100, 'Default'),
          SEQ_ID
      FROM APEX_collections
    WHERE collection_name = 'ARGYLL_INVOICES'
    order by seq_id

  • URL in lieu PH consumed within 3 months from the date of PH

    Hi friends
    I achieved Unrecorded leave in lieu of PH,through writing PCR but i am having another doubt..This URL in lieu of PH has to be consumed within 3 months from the date of public holiday,how to achieve this??any suggestions from u friends???
    Thanks&best regds
    Shaila

    I have asked a moderator to provide assistance, they will post an invite on this thread.
    They are the only BT employees on this forum, and are a UK based team of people, who take personal ownership of your problem.
    Once you get a reply, make sure that you are logged into the forum, then click on their name, you will see a screen like this. Click on the link as shown below.
    Please do not send them a personal message, as they cannot deal with service issues that way.
    For your own security, do not post any personal details, on this forum. That includes any tracking number you are give.
    They will respond either by phone or e-mail, when its your turn in the queue.
    Please use the tracked e-mail, to reply, not via the forum. Thanks
    This is the form you should see when you click on the link. If you do not see this form, then you have selected the wrong link.
    When you submit the form, you will receive an enquiry number, so please keep a note of it
    There are some useful help pages here, for BT Broadband customers only, on my personal website.
    BT Broadband customers - help with broadband, WiFi, networking, e-mail and phones.

  • How to avoid duplicate data while inserting from sample.dat file to table

    Hi Guys,
    We have issue with duplicate data in flat file while loading data from sample.dat file to table. How to avoid duplicate data in control file.
    Can any one help me on this.
    Thanks in advance!
    Regards,
    LKR

    No, a control file will not remove duplicate data.
    You would be better to use an external table and then remove duplicate data using SQL as you query the data to insert it to your destination table.

  • Subtracting months from current date

    how to subtract months from current date in mysql

    You are in an Oracle forum, so the Oracle answer is: use add_months(sysdate,-2) to subtract two months from the current date.
    Regards,
    Rob.

  • How to get Week,Month and Year details from a date column

    Hi frenz,
    I've a column like tran_date which is a date column..... I need the next week details based on this column and so on...
    I need month and year details as well based on this tran_date column.... can any one tell me how...
    Thanks in advance

    My example for objects:
    create or replace type date_object as object
      centure number,
      year    number,
      month   number,
      day     number,
      hour    number,
      minute  number,
      second  number,
      daypart number,
      week    number,
      constructor function date_object(p_dt date)
        return SELF as result
    create or replace type body date_object is
      constructor function date_object(p_dt date)
        return SELF as result
      as
      begin
        SELF.centure:= trunc(to_char(p_dt,'YYYY')/100);
        SELF.year:=    to_char(p_dt,'YYYY');
        SELF.month:=   to_char(p_dt,'MM');
        SELF.day:=     to_char(p_dt,'DD');
        SELF.hour:=    to_char(p_dt,'HH24');
        SELF.minute:=  to_char(p_dt,'MI');
        SELF.second:=  to_char(p_dt,'SS');
        SELF.daypart:= p_dt-trunc(p_dt,'DD');
        SELF.week:=    to_char(p_dt,'IW');
        return;
      end;
    end;
    select date_object(sysdate),
           date_object(sysdate).year
    from dual;Regards,
    Sayan M.

  • How to get previous 2 months from current date in a dropdown?

    Hello Experts ,
                           In the application which I am developing, there is a requirement wherein , I want to Populate current month and previous two month in a drop down depending upon today's date. please help.
    Thanks & Regards,
    Pratbha Shukla

    The internal format for dates is yyyymmdd.  Therefore you can just grab the month value from the date:
    data lv_month type FCMNR.
    lv_month = lv_date+4(2).
    Just subtract from the month to get the two previous.
    data lv_previous1 type FCMNR.
    data lv_previous2 type FCMNR.
    if lv_month = 1.
    lv_previous1 = '12'.
    else.
    lv_previous1 - lv_month - 1.
    endif.
    if lv_previous1 = 1.
    lv_previous2 = '12'.
    else.
    lv_previous2 - lv_previous1 - 1.
    endif.
    Then do your lookup for the month name by reading the table returned from function module MONTH_NAMES_GET.

  • How to determine most recent date from the date column of internal table

    Dear friends
    would you like to tell me. how i determine the most recently changed record by looking at date and time from internal table i am not supposed to sort the table by date and time... I must check date and time with other records date and time to determine which record is most recently changed...
    here the scenario is.
    id idnumber chdate chtime
    1 123456 20060606 135312
    2 123456 20060606 135900
    3 123456 20060606 132300
    4 123457 20060606 140000
    5 123457 20060606 142500
    in the above scenario i must keep in my mind that the most recently changed record is identical to its idnumber i can say that:
    the record should be fetched this way
    id idnumber chdate chtime
    3 123456 20060606 132300
    5 123457 20060606 142500
    because here the id 3 is the most recently changed in the idnumber 123456
    where id 5 is the most recently changed in the idnumber 123457
    please help me to determin how i am supposed to carry out this task any suggestion, code will be great help of mine.
    regards
    Naim

    After testing my suggestion above, I realized that it doesn't work because the delete adjacent actually will keep the first one and delete the rest.  I'm working with Srinivas's code a bit now,  I think it is almost what you want.  I am under the impression that you dont' want to HIGHest date/time, but just the last record of the sequence, if this is the case, then this code will help.  Here we will assign an index to each record per the idnumber, that way we can sort it and get the lastest record.
    report zrich_0001.
    types: begin of itab_type,
            id       type i,
            idnumber type i,
            chdate   like sy-datum,
            chtime   like sy-uzeit.
    types: end of itab_type.
    types: begin of itab_type2,
            id       type i,
            idnumber type i,
            index    type i,
            chdate   like sy-datum,
            chtime   like sy-uzeit.
    types: end of itab_type2.
    data: itab     type table of itab_type with header line,
          itab2    type table of itab_type2 with header line,
          prev_rec type itab_type.
    data: v_id type i.
    start-of-selection.
      itab-id       = 1.
      itab-idnumber = 123456.
      itab-chdate   = '20060606'.
      itab-chtime   = '135312'.
      append itab. clear itab.
      itab-id       = 2.
      itab-idnumber = 123456.
      itab-chdate   = '20060606'.
      itab-chtime   = '135900'.
      append itab. clear itab.
      itab-id       = 3.
      itab-idnumber = 123456.
      itab-chdate   = '20060606'.
      itab-chtime   = '142500'.
      append itab. clear itab.
      itab-id       = 4.
      itab-idnumber = 123457.
      itab-chdate   = '20060606'.
      itab-chtime   = '140000'.
      append itab. clear itab.
      itab-id       = 5.
      itab-idnumber = 123457.
      itab-chdate   = '20060606'.
      itab-chtime   = '120000'.
      append itab.
      clear itab.
    <b>  data: counter type i.
    * Assign an index to each row per idnumber
      loop at itab.
        on change of itab-idnumber.
        if sy-tabix > 1.
          clear counter.
          endif.
        endon.
        clear itab2.
        move-corresponding itab to itab2.
        counter = counter + 1.
        itab2-index = counter.
        append itab2.
      endloop.
    * Sort it and get rid of older records.
      sort itab2  by idnumber ascending
                     index descending.
      delete adjacent duplicates from itab2 comparing idnumber.</b>
      read table itab2 with key idnumber = '123456'.
      write:/ itab2-chdate, itab2-chtime.
      read table itab2 with key idnumber = '123457'.
      write:/ itab2-chdate, itab2-chtime.
    Regards,
    Rich Heilman

  • How to get date prompts from one date column

    i have a requirement where i have to filter the data between two date prompts. i have only one date column and the date in the prompts shuld be selected by calendar.
    i have seen may approaches to do this and i got one where two dummy date columns should be declared in repository and used to define the date prompts.
    but using other methods i could not get the calendar option in prompt.
    but is there any other way to get the prompts with calndar selection without defining the dummy columns in repository
    thanks

    you can do that first select the date column you want to use in dashboard prompt then select another column and in the dashboard prompts then open the fx of the date prompt you first selected copy that and paste it in the second column and in the control section click on calender it will work you can use same date column as two prompts with out creating new column.

Maybe you are looking for

  • Is mobile me the only app where I can upload photos to create albums to share?

    Also, when I try to open the Gallery  appl it does not accept the MobileMe ID and password I set up when I downloaded "find my iPad".  What gives?

  • Mail for large amount of data

    Hey guys, I just switched to Mac (and I love it ;)) and now I am searching for a mail program to host my office pop mail account. I get normally around 5000 messages / month, totalling over 3GB, mostly pictures. Can Mail handle the amount of data, or

  • Character styles that accommodate different fonts?

    I suspect this is hopeless, but I thought I'd ask in case anyone has a great idea I can't think of. I use a basic formatting script that runs through a newly placed text file and makes a series of typographical corrections -- getting rid of double sp

  • Every 10 min I get a message

    An operation on the server timed out. The server may be down, overloaded, or there may be too much net traffic. This has been going on for days.  I have changed ports to no avail.  I have checked my passwords and they are OK.  Anyone got any ideas as

  • Descargar adobe ilustrator de manera gratuita

    Descargar gratis adobe ilustrator