Check if date falls in current month

Hi All,
How to check if a date value falls within the current month or its older than current month in a simple logic? I have to do this without using too complicated a logic..
Thanks in advance.

Hi ,Check This
SQL> select to_number(to_char(sysdate,'mm')) today,to_number(to_char(sysdate-1,'mm')) yesterday,case
to_number(to_char(sysdate,'mm'))-to_number(to_char(sysdate-1,'mm'))
  2  when 0 then 'Same Month'
  3  else 'Different Month' end months from dual;
     TODAY  YESTERDAY MONTHS
         1          1 Same Month
SQL> select to_number(to_char(sysdate,'mm')) today,to_number(to_char(sysdate-30,'mm')) yesterday,cas
e to_number(to_char(sysdate,'mm'))-to_number(to_char(sysdate-30,'mm'))
  2  when 0 then 'Same Month'
  3  else 'Different Month' end months from dual;
     TODAY  YESTERDAY MONTHS
         1         12 Different MonthRegards
Umi

Similar Messages

  • How to set the filter on a report to show the data for the Current Month

    Hi all,
    I am working on a report, which currently has this filter: Date First Worked is greater than or equal to 10/01/2010. This reports show the data for the current month, so at the beginning of each month we have to remember to change the date on the filter.
    Does anyone know what the criteria should say, so that it automatically changes and shows the information for the current month, without us having to go in and change anything?
    Any help would be greatly appreciated!
    Thanks,
    AA

    You need to add a session variable to date fir worked assuming that this is a date field.
    To do this open up the filter on the field then at then press add Variable then "session" and enter the following CURRENT_MONTH into the Server Variable section.

  • Load data only for current month using ABAP Routine

    Hi Everyone,
    I am loading data from R/3 using the 0HR_PA_OS_1 extractor. This requirement is to load the position numbers from R/3. Using the extractor for a given position 28 I get the following dataset results.
    CALMONTH  POSITION
    11-2004           28
    12-2004           28
    01-2005           28
    02-2005           28
          |
    07-2007          28     CURRENT DATE
    Now when I pull data in BW I only want to load the record for most current i.e. 07-2007. I DO NOT want that ALL the records since the day the position was created should be loaded.
    Now I do understand this can be achieved using a ABAP routine in the INFOPACKAGE. Below is the routine that I am using and what it is doing is that it is only bringing in the first record.
    data: l_idx like sy-tabix.
      clear: l_idx.
      read table l_t_range with key
           fieldname = 'CALMONTH'.
      l_idx = sy-tabix.
    Current month only
      l_t_range-low = sy-datum(6).      "Current month
    l_t_range-high.
      l_t_range-option = 'EQ'.                           "equals
    l_t_range-sign = 'I'.
      modify l_t_range index l_idx.
      p_subrc = 0.
    Can anyone suggest a solution as to why this is happening?
    Thanks,
    Rahul

    One explanation would be
    - If there is no CALMONTH selection values specified in the selection tab, l_t_range would be empty. This would mean there would be no line for CALMONTH selection, and the code won't modify the l_t_range.
    If this is true, you need to check sy-subrc after reading from the itab.
    data: l_idx like sy-tabix.
    clear: l_idx.
    read table l_t_range with key fieldname = 'CALMONTH'.
    if sy-subrc = 0.
    l_idx = sy-tabix.
    * Current month only
    l_t_range-low = sy-datum(6). "Current month
    * l_t_range-high.
    l_t_range-option = 'EQ'. "equals
    * l_t_range-sign = 'I'.
    modify l_t_range index l_idx.
    else.   
    move 'CALMONTH' to l_t_range-fieldname.
    l_t_range-low = sy-datum(6).
    l_t_range-sign = 'I'.
    l_t_range-option = 'EQ'.
    append l_t_range.
    endif.
    p_subrc = 0.

  • Check 3G data usage for previous months?

    Where do I go to check my 3G iPad2 data usage for previous months?
    I look in the Settings / Cellular Data / View Account - but only see the current month.
    I tried to create a My Verizon account on the verizon wireless web site using my iPad phone number but I get the error "We're sorry, but at this time you cannot register your account for My Verizon. Please access your account information on your device."
    I installed the "My Verizon" app for ipad from the App Store but I get "System under maintenance.  Please Try again." all the time.
    Is there someplace else I can see previous months data usage?  I would like to get a sense how much I have used in the past.
    Thanks
    Joe

    Dear AdamE+VZW and AntoniioC_VZW
    Have you actually tried the advice you gave?  I'm 6 days into my billing cycle.  The furthest back I am able to see data traffic is 6 days.
    The specific navigation path "View Bill --> I Want To...  --> Month ---> Usage Details --> Data"  does not currently exist.
    As far as I can tell, AdamE's claim that "You can easily see the past six months of data usage on our website " is untrue.
    The report generated by the "Account Analysis" is plainly false as well.  It reports that both of my data phones used exactly 1024.00 MB in February, March, and April. (sic: 2 decimal points!!).  That is an exceedingly unlikely coincidence, and flatly contradicts the current month summary which reports that one of my phones has used only 23 MB, and the other line even less.  The "Account Analysis" has a bug so serious as to render its data traffic output absolutely useless.  Since it is providing false output, it should be removed from the site until it can be fixed to generate accurate reports.
    I can't even find a way to see my prior month's summary bill, though I can't be sure it is unavailable since the site is large.  But I can say that when a customer spends 15 minutes clicking around a site trying to find their prior month's bill (not merely the bill's dollar amount, but the bill's usage summary) and fails, the site navigation should be improved!!

  • How to get monday date if you enter any date for the current month.

    Hi All,
    I have requirement to create on char variable for 0calday and need to code in such a way that if you enter the date
    For example today is 20th March, the following dates will be returned.
    February 4th, 11th, 18th, 25th 
    March 3rd, 10th, 17th, 24th 31st
    i.e date of Monday of current month and previous month.
    Thanks in Advance.
    Kind Regards,
    Raghu

    Hi,
    Have a look on this code.
    data :  zdate like VTBBEWE-DVALUT.
    data : day_val(1) type n.
          CALL FUNCTION 'DATE_COMPUTE_DAY'
          EXPORTING
            DATE         = your_date
          IMPORTING
            DAY = day_val.
    if day_val = 1.
    ' Place ur code for monday because day_val = 1 then it is monday.
    endif.
    Vivek

  • Year to Date Report (excluding current month)

    Hello,
    I need a formula to pick data from 01/01/2010 to the end of the previous month.
    I'm familiar with using Today-1 etc but require a formula that enables me to run the report at any time during the month without changing the parameters.
    Thanks,
    Joe

    To calculate the start of the current year...
    DateAdd("yyyy", DateDiff("yyyy", #1/1/1900#, CurrentDate), #1/1/1900#)
    which will return: 1/1/2010  12:00:00AM
    Technically, the end of last month is the exact same time as the start of the current (12:00:00.000 midnight)... So...
    DateAdd("m", DateDiff("m", #1/1/1900#, CurrentDate), #1/1/1900#)
    which will return 10/1/2010  12:00:00AM
    But for viewing purposes, people tend to not like seeing 10/1/2010, when they are looking for 9/30/2010... so you can use this. Just be aware that you'll loose that last 1 second (most people don't mind)
    DateAdd("s", -1, DateAdd("m", DateDiff("m", #1/1/1900#, CurrentDate), #1/1/1900#))
    which will return 9/30/2010  11:59:59PM
    HTH,
    Jason

  • Get last date of the current month

    Hi all,
       Is there any FM used to get the last date of
    sy-datum.
    Regards,
    bala

    check..
    RE_LAST_DAY_OF_MONTH
    SG_PS_GET_LAST_DAY_OF_MONTH
    parameters: p_fdate like sy-datum.
    DATA: M_DATE LIKE SY-DATUM,
    CALL FUNCTION 'LAST_DAY_OF_MONTHS' "#EC EXISTS
    EXPORTING
    DAY_IN = P_FDATE
    IMPORTING
    LAST_DAY_OF_MONTH = M_DATE.
    case mdate+3(2).
    when 30.
    write: '30 days'.
    when 28.
    write: '28 days'.
    when 29.
    write: '29 days'.
    when 31.
    write: '31 days'.
    endcase.

  • Return Current month Data:Help needed in modifying this code of a Procedure

    Hello Folks i have this scenario where i need to modify this code so that it has to return data from the Current month First Day to the previous Day if its a daily report and previous month data if its a monthly report.
    I have no clue how to modify this code below. Currently the code is returning data for Monthly reports for the previous month. Does anyone have any idea how to modify so that the code meets the requirements of both daily and monthly reprts.
    BEGIN
    if v_lowdate is null or v_highdate is null then
    select to_number(to_char(sysdate, 'DD')) into v_cur_day from dual;
    if v_cur_day < 25 then
    -- this is for the previous month run
    Select Add_Months(trunc(sysdate, 'MONTH'), -1)
    INTO V_LOWDATE
    FROM DUAL;
    SELECT Last_Day(ADD_Months(Sysdate, -1)) INTO V_Highdate From Dual;
    else
    -- this is for the current month run
    Select trunc(sysdate, 'MONTH') INTO V_LOWDATE FROM DUAL;
    SELECT Last_Day(Sysdate) INTO V_Highdate From Dual;
    end if;
    end if;
    Thanks
    Edited by: user11961230 on Sep 30, 2009 8:34 PM

    Hi Frank, This is code till the "modifying Code" which we were working. I will post the code after the "modifying Code" in the next reply. Thanks
    CREATE OR REPLACE PROCEDURE "POPULATE_RECOVERY_ACTIVITYHN"(p_lowdate date,
    p_highdate date) IS
    v_lowdate date := p_lowdate;
    v_highdate date := p_highdate;
    v_error_code NUMBER(20);
    v_error_text VARCHAR2(300);
    v_recovery_id Recovery.Recovery_ID%type;
    v_loop_control Number(20);
    v_settlement_id recovery.settlement_id%type;
    V_Event_ID Event.Event_ID%Type;
    V_Event_Case_ID Event_Case.Event_Case_ID%Type;
    V_Recovery_Month Varchar2(100);
    V_Major_Company Major_Client.Major_Client_Name%Type;
    V_Company Client.Client_Name%Type;
    V_Client_Policy_Identifier Varchar2(100);
    V_Lan_ID Varchar2(10) := 'TROVERIS';
    V_Recovery_Account Client.Account_Number%Type;
    V_AccountA Number(2) := 0;
    V_AccountB Number(2) := 0;
    V_Unit Event_Client_Field.Client_Field_Data%Type;
    V_Market Event_Client_Field.Client_Field_Data%Type;
    V_case_open_date Event_case.Open_Date%type;
    V_Employer_Group_Code Employer_Group.Employer_Group_Code%Type;
    V_Unknown1 Number(2) := 0;
    V_Fee_Schedule_Code Event_Case.Fee_Schedule_Code%Type;
    V_Total_Fee_Percent Number(20, 2) := 0.00;
    V_Subrogation_Fee_Percent Number(20, 2) := 0.00;
    V_Unknown2 Number(2) := NULL;
    V_Unknown3 Number(2) := NULL;
    V_TOTAL_MEDICAL Number(20, 2) := 0.00;
    V_Recovery_Amount Number(20, 2) := 0.00;
    V_Total_Tax Number(20, 2) := 0.00;
    V_Administrative_Tax Number(20, 2) := 0.00;
    V_Total_NonCash_Fee Number(20, 2) := 0.00;
    V_Total_NonCash_Positive Number(20, 2) := 0.00;
    V_Total_NonCash_Negative Number(20, 2) := 0.00;
    V_Total_Recovery Number(20, 2) := 0.00;
    V_Total_NonCash_Fee_Positive Number(20, 2) := 0.00;
    V_Total_NonCash_Fee_Negative Number(20, 2) := 0.00;
    V_Total_Admin_Fee Number(20, 2) := 0.00;
    V_Total_Fee Number(20, 2) := 0.00;
    V_Total_NonCash_Tax_Positive Number(20, 2) := 0.00;
    V_Total_NonCash_Tax_Negative Number(20, 2) := 0.00;
    report_type                  Varchar2(2);
    v_gl_num client.gl_num%type; -- *002*
    v_net_billable client.net_billable%type; -- *003*
    vevent_id event.event_id%type; -- *006*
    v_prev_event event.event_id%type; -- *006*
    v_prev_case event_case.event_case_id%type; -- *006*
    v_tot_recovery recovery.amount%type; -- *006*
    v_rec_amount recovery.amount%type; -- *006*
    v_prev_rec_amt recovery.amount%type; -- *006*
    v_prev_rec_month recovery_activity.recovery_month%type; -- *006*
    v_tot_fee recovery_activity.total_fee%type; --*006*
    v_mth_rev unbundled_recoveries.monthly_revenue%type; -- *006*
    v_diff number(18, 2); -- *006*
    v_nc_count number := 0; -- *006*
    v_c_count number := 0; -- *006*
    v_nc_tot recovery.amount%type; -- *006*
    v_used_rev recovery_activity.total_fee%type; -- *006*
    v_use_mth_rev unbundled_recoveries.monthly_revenue%type := 0; -- *006*
    v_use_nc_mth_rev unbundled_recoveries.monthly_revenue%type := 0; -- *006*
    v_prev_netbill client.net_billable%type; -- *006*
    v_event_type event.event_type_code%type;
    v_date_typed event.date_typed%type;
    v_acc_client_id client.acc_client_id%Type;
    v_Recovery_Revenue_GL_Num client.recovery_revenue_gl_num%Type;
    v_Funds_Due_GL_num client.funds_due_gl_num%Type;
    v_lob Varchar2(20);
    v_nc_recovery_id recovery.recovery_id%Type;
    /*Changed the Client_Policy_Identifier to concatenate the Retlation to insured code instead of the description
    which was exceeding the column size in the table. SWL 09/03/02. Checked with the Design Doc.*/
    CURSOR RECOVERY_INFO IS
    SELECT Event.Event_ID,
    Event_Case.Event_Case_ID,
    TO_CHAR(Recovery.Recovery_Date, 'FMMONTHYYYY') As Recovery_Month,
    Major_Client.Major_Client_Name AS Major_Company,
    -- Client.Client_Name AS Company,
    -- nvl(client.legacy_client_id,'DC')||'-'||substr(Client.Client_Name,1,55) AS Company, -- SWL 04/01/04 52653
    substr(nvl(client.legacy_client_id,
    decode(client.client_id, 1, 'DC', client.client_code)) || '-' ||
    Client.Client_Name,
    1,
    60) AS Company,
    Event.Client_Policy_Identifier ||
    Event_Case.Relation_To_Insured_code as Client_Policy_Identifier,
    Client.Account_Number as Recovery_Account,
    Employer_Group.Employer_Group_Code,
    Event_Case.Fee_Schedule_Code,
    Recovery_ID,
    Event_case.Open_Date,
    '(' || recovery.recovery_transaction_internal || ')' ||
    l.recovery_transaction_descripti, --fml 110276
    recovery.settlement_id,
    trim(client.gl_num), -- *002*
    nvl(trim(client.net_billable), 'N'), -- *003*
    recovery.amount, -- *006*,
    event.event_type_code,
    event.date_typed,
    recovery_id,
    Client.ACC_CLIENT_ID,
    Recovery_Revenue_GL_Num,
    Funds_Due_GL_num
    FROM Recovery,
    Settlement,
    Event_Case,
    Event,
    Employer_Group,
    Client,
    Major_Client,
    recovery_transaction_lookup l
    Where to_date(Recovery.Recovery_Date, 'DD-MON-RR') between
    TO_DATE(v_lowdate, 'DD-MON-RR') and
    TO_DATE(v_highdate, 'DD-MON-RR')
    AND Settlement.Settlement_id = Recovery.Settlement_id
    AND Settlement.Event_Case_ID = Event_Case.Event_Case_id
    AND Event_Case.Event_ID = Event.Event_ID
    AND Event.Employer_Group_ID = Employer_Group.Employer_Group_ID(+)
    AND Event.Client_ID = Client.Client_ID
    AND Client.Major_Client_id = Major_Client.Major_Client_ID(+)
    and recovery.settlement_id not in
    (select settlement_id
    from recovery
    where to_date(Recovery.Recovery_Date, 'DD-MON-RR') between
    TO_DATE(v_lowdate, 'DD-MON-RR') and
    TO_DATE(v_highdate, 'DD-MON-RR')
    AND recovery_transaction_internal in
    ('05', '50', '52', '51'))
    --001
    and    client.invoice_flag = 'N'            *005* commenting
    -- SWL 05/03/05 #71231
    and event.event_id in
    (select event_id
    from event_end_user eeu
    where eeu.active_flag = 'Y'
    and eeu.owner_flag = 'Y'
    and eeu.end_user_id in
    (select end_user_id
    from end_user
    where end_user.research_internal_user = 'Y'))
    and recovery.recovery_transaction_internal =
    l.recovery_transaction_internal --fml 110276
    order by event.event_id, recovery.amount; -- *006*
    -- SWL 05/03/05 #71231
    -- end of 001
    -- SWL 11/10/03 # 52743
    -- *006*
    CURSOR get_recovery(vevent_id event.event_id%type) IS
    SELECT sum(r.amount)
    FROM Recovery r
    Where to_date(r.Recovery_Date, 'DD-MON-RR') between
    TO_DATE(v_lowdate, 'DD-MON-RR') and
    TO_DATE(v_highdate, 'DD-MON-RR')
    and r.event_id = vevent_id
    and r.settlement_id not in
    (select settlement_id
    from recovery
    where to_date(Recovery.Recovery_Date, 'DD-MON-RR') between
    TO_DATE(v_lowdate, 'DD-MON-RR') and
    TO_DATE(v_highdate, 'DD-MON-RR')
    AND recovery_transaction_internal in
    ('05', '50', '52', '51'))
    and r.event_id in
    (select event_id
    from event_end_user eeu
    where eeu.active_flag = 'Y'
    and eeu.owner_flag = 'Y'
    and eeu.end_user_id in
    (select end_user_id
    from end_user
    where end_user.research_internal_user = 'Y'));
    CURSOR RECOVERY_INFO_NC IS
    SELECT distinct Event.Event_ID,
    Event_Case.Event_Case_ID,
    TO_CHAR(Recovery.Recovery_Date, 'FMMONTHYYYY') As Recovery_Month,
    Major_Client.Major_Client_Name AS Major_Company,
    -- Client.Client_Name AS Company,
    -- nvl(client.legacy_client_id,'DC')||'-'||substr(Client.Client_Name,1,55) AS Company, /* SWL 04/01/04 52653 */
    substr(nvl(client.legacy_client_id,
    decode(client.client_id,
    1,
    'DC',
    client.client_code)) || '-' ||
    Client.Client_Name,
    1,
    60) AS Company,
    Event.Client_Policy_Identifier ||
    Event_Case.Relation_To_Insured_code as Client_Policy_Identifier,
    Client.Account_Number as Recovery_Account,
    Employer_Group.Employer_Group_Code,
    Event_Case.Fee_Schedule_Code,
    '(' || recovery.recovery_transaction_internal || ')' ||
    l.recovery_transaction_descripti, --fml 110276
    recovery.settlement_id,
    trim(client.gl_num), -- *002*
    nvl(trim(client.net_billable), 'N'), -- *003*
    recovery.amount,-- *006*
    recovery.recovery_id,
    event.event_type_code,
    event.date_typed,
    Client.ACC_CLIENT_ID,
    Recovery_Revenue_GL_Num,
    Funds_Due_GL_num
    FROM Recovery,
    Settlement,
    Event_Case,
    Event,
    Employer_Group,
    Client,
    Major_Client,
    recovery_transaction_lookup l
    Where to_date(Recovery.Recovery_Date, 'DD-MON-RR') between
    TO_DATE(v_lowdate, 'DD-MON-RR') and
    TO_DATE(v_highdate, 'DD-MON-RR')
    AND Settlement.Settlement_id = Recovery.Settlement_id
    AND Settlement.Event_Case_ID = Event_Case.Event_Case_id
    AND Event_Case.Event_ID = Event.Event_ID
    AND Event.Employer_Group_ID = Employer_Group.Employer_Group_ID(+)
    AND Event.Client_ID = Client.Client_ID
    AND Client.Major_Client_id = Major_Client.Major_Client_ID(+)
    and recovery.settlement_id in
    (select settlement_id
    from recovery
    where to_date(Recovery.Recovery_Date, 'DD-MON-RR') between
    TO_DATE(v_lowdate, 'DD-MON-RR') and
    TO_DATE(v_highdate, 'DD-MON-RR')
    --001
    AND recovery.recovery_transaction_internal in
    ('05', '50', '52', '51')
    and    client.invoice_flag = 'N'   *005* commenting
    /* SWL 05/03/05 #71231 */
    and event.event_id in
    (select event_id
    from event_end_user eeu
    where eeu.active_flag = 'Y'
    and eeu.owner_flag = 'Y'
    and eeu.end_user_id in
    (select end_user_id
    from end_user
    where end_user.research_internal_user = 'Y'))
    and recovery.recovery_transaction_internal =
    l.recovery_transaction_internal --fml 110276
    order by event.event_id, recovery.amount; -- *006*
    /* SWL 05/03/05 #71231 */
    --end of 001
    -- *006*
    CURSOR get_recovery_nc(vevent_id event.event_id%type) IS
    SELECT sum(r.amount)
    FROM Recovery r
    Where to_date(r.Recovery_Date, 'DD-MON-RR') between
    TO_DATE(v_lowdate, 'DD-MON-RR') and
    TO_DATE(v_highdate, 'DD-MON-RR')
    AND r.event_id = vevent_id
    and r.settlement_id in
    (select settlement_id
    from recovery
    where to_date(Recovery.Recovery_Date, 'DD-MON-RR') between
    TO_DATE(v_lowdate, 'DD-MON-RR') and
    TO_DATE(v_highdate, 'DD-MON-RR'))
    AND recovery_transaction_internal in ('05', '50', '52', '51')
    and r.event_id in
    (select event_id
    from event_end_user eeu
    where eeu.active_flag = 'Y'
    and eeu.owner_flag = 'Y'
    and eeu.end_user_id in
    (select end_user_id
    from end_user
    where end_user.research_internal_user = 'Y'));
    CURSOR Recovery_Totals_Nc IS
    Select Recovery_Detail.Recovery_Id, /* SWL 07/01/04 59016 */
    max(NVL(Recovery_Detail.Fees_Percent, 0) +
    NVL(Recovery_Detail.Admin_Percent, 0)) as Total_Fee_Percent,
    max(NVL(Recovery_Detail.Fees_Percent, 0)) as Subrogation_Fee_Percent,
    max(NVL(Recovery.Amount, 0)) as Recovery_Amount, /* SWL 04/01/04 52653 */
    Sum(NVL(Recovery_detail.Fees, 0) + NVL(Recovery_Detail.Admin, 0)) as Total_Fee,
    Sum(NVL(Recovery_Detail.Fees_Taxes, 0) +
    NVL(Recovery_Detail.Admin_Taxes, 0)) as Total_Tax,
    Sum(NVL(Recovery_Detail.Admin_Taxes, 0)) as Administrative_tax,
    Sum(NVL(Recovery_Detail.Admin, 0)) as Total_Admin_Fee,
    sum(recovery.retained_by_client) as Non_cash_fee, --fml 110276
    sum(recovery.allocation_check_amount) as cash --fml 110276
    From Settlement, Recovery, Recovery_Detail
    Where Recovery.settlement_id = v_settlement_id
    And recovery.recovery_id = v_recovery_id
    And Settlement.Settlement_id = Recovery.Settlement_id
    And Recovery.Recovery_id = Recovery_detail.Recovery_id(+)
    and to_date(Recovery.Recovery_Date, 'DD-MON-RR') between
    TO_DATE(v_lowdate, 'DD-MON-RR') and
    TO_DATE(v_highdate, 'DD-MON-RR') /*SWL 12/03/04 */
    -- Group by Recovery_Detail.Fees_Percent; /* SWL 04/01/04 52653 */
    Group by Recovery_Detail.recovery_id;
    v_cash_recovery recovery_activity.cash_recovery%type;
    CURSOR Recovery_Totals_Positive_Nc IS
    -- Select Sum(Recovery.Amount) as Total_NonCash_Positive, /* SWL 04/01/04 52653 */
    Select max(Recovery.Amount) as Total_NonCash_Positive,
    Sum(NVL(Recovery_Detail.Fees_Taxes, 0) +
    NVL(Recovery_Detail.Admin_Taxes, 0)) as Total_NonCash_Tax_Positive
    From Settlement, Recovery, Recovery_detail
    Where Recovery.settlement_id = v_settlement_id
    And Settlement.Settlement_id = Recovery.Settlement_id
    and recovery.recovery_id = v_recovery_id /* SWL 07/01/04 59016 */
    And Recovery.Amount >= 0
    And Recovery.Recovery_id = Recovery_detail.Recovery_id(+)
    And Recovery.Recovery_Transaction_Internal in
    ('05', '50', '52', '51')
    -- Group by Recovery_Detail.Fees_Percent; /* SWL 04/01/04 52653 */
    Group by Recovery_Detail.recovery_id;
    CURSOR Recovery_Totals_Negative_Nc IS
    -- Select Sum(Recovery.Amount) as Total_NonCash_Negative, /* SWL 04/01/04 52653 */
    Select max(Recovery.Amount) as Total_NonCash_Negative,
    Sum(NVL(Recovery_Detail.Fees_Taxes, 0) +
    NVL(Recovery_Detail.Admin_Taxes, 0)) as Total_NonCash_Tax_Negative
    From Settlement, Recovery, Recovery_Detail
    Where Recovery.settlement_id = v_settlement_id
    And Settlement.Settlement_id = Recovery.Settlement_id
    and recovery.recovery_id = v_recovery_id /* SWL 07/01/04 59016 */
    And Recovery.Amount < 0
    And Recovery.Recovery_id = Recovery_detail.Recovery_id(+)
    And Recovery.Recovery_Transaction_Internal in
    ('05', '50', '52', '51')
    Group by Recovery_Detail.recovery_id;
    -- Group by Recovery_Detail.Fees_Percent; /* SWL 04/01/04 52653 */
    /* SWL 11/10/03 # 52743 */
    CURSOR Event_Client_Unit IS
    Select e.Client_Field_Data as Unit
    From Event_Client_Field e, recovery r
    Where r.Event_ID = e.Event_ID
    AND r.Recovery_ID = V_Recovery_ID
    AND e.Client_Field_Name = 'UNIT';
    CURSOR Bill_totals IS
    Select mv_billdetail_case_sum.sum_paid as TOTAL_MEDICAL
    From mv_billdetail_case_sum
    where mv_billdetail_case_sum.event_id = V_Event_ID;
    CURSOR NonCash_Fee IS
    Select NVL(Sum(Recovery.Amount), 0) as Total_NonCash_Fee
    From Settlement, Recovery
    Where Recovery.Recovery_ID = V_Recovery_ID
    And Settlement.Settlement_id = Recovery.Settlement_id
    And Recovery.
    Recovery_Transaction_Internal in ('05', '50', '52', '51');
    /* SWL 04/01/04 52653 */
    CURSOR Recovery_Totals IS
    Select round(avg(NVL(Recovery_Detail.Fees_Percent, 0) +
    NVL(Recovery_Detail.Admin_Percent, 0)),
    2) as Total_Fee_Percent,
    round(avg(NVL(Recovery_Detail.Fees_Percent, 0)), 2) as Subrogation_Fee_Percent,
    max(NVL(Recovery.Amount, 0)) as Recovery_Amount,
    Sum(NVL(Recovery_detail.Fees, 0) + NVL(Recovery_Detail.Admin, 0)) as Total_Fee,
    Sum(NVL(Recovery_Detail.Fees_Taxes, 0) +
    NVL(Recovery_Detail.Admin_Taxes, 0)) as Total_Tax,
    Sum(NVL(Recovery_Detail.Admin_Taxes, 0)) as Administrative_tax,
    Sum(NVL(Recovery_Detail.Admin, 0)) as Total_Admin_Fee
    From Settlement, Recovery, Recovery_Detail
    Where Recovery.Recovery_ID = V_Recovery_ID
    And Settlement.Settlement_id = Recovery.Settlement_id
    And Recovery.Recovery_id = Recovery_detail.Recovery_id(+)
    Group by Recovery_Detail.recovery_id;
    CURSOR Recovery_Totals_Positive IS
    /* Select Sum(Recovery.Amount) as Total_NonCash_Positive,
    Sum(NVL(Recovery_Detail.Fees_Taxes,0)+ NVL(Recovery_Detail.Admin_Taxes,0)) as Total_NonCash_Tax_Positive
    */ /* SWL 04/01/04 52653 */
    Select max(Recovery.Amount) as Total_NonCash_Positive,
    Sum(NVL(Recovery_Detail.Fees_Taxes, 0) +
    NVL(Recovery_Detail.Admin_Taxes, 0)) as Total_NonCash_Tax_Positive
    From Settlement, Recovery, Recovery_detail
    Where Recovery.Recovery_ID = V_Recovery_ID
    And Settlement.Settlement_id = Recovery.Settlement_id
    And Recovery.Amount >= 0
    And Recovery.Recovery_id = Recovery_detail.Recovery_id(+)
    And Recovery.Recovery_Transaction_Internal in ('04', '17', '15') /*SWL 10/05/04 #63919*/--*009* added 15
    Group by Recovery_Detail.recovery_id;
    -- Group by Recovery_Detail.Fees_Percent; /* SWL 04/01/04 52653 */
    CURSOR Recovery_NonFEE_Positive IS
    Select Sum(NVL(Recovery_Detail.Fees, 0) + NVL(Recovery_Detail.Admin, 0)) as Total_NonCash_Fee_Positive
    From Settlement, Recovery, Recovery_detail
    Where Recovery.Recovery_ID = V_Recovery_ID
    And Settlement.Settlement_id = Recovery.Settlement_id
    And Recovery.Amount >= 0
    And Recovery.Recovery_id = Recovery_detail.Recovery_id(+)
    And Recovery.Recovery_Transaction_Internal in
    ('05', '50', '52', '51')
    Group by Recovery_Detail.recovery_id;
    -- Group by Recovery_Detail.Fees_Percent; /* SWL 04/01/04 52653 */
    CURSOR Recovery_Totals_Negative IS
    /* Select Sum(Recovery.Amount) as Total_NonCash_Negative,*/ /* SWL 04/01/04 52653 */
    Select max(Recovery.Amount) as Total_NonCash_Negative,
    Sum(NVL(Recovery_Detail.Fees_Taxes, 0) +
    NVL(Recovery_Detail.Admin_Taxes, 0)) as Total_NonCash_Tax_Negative
    From Settlement, Recovery, Recovery_Detail
    Where Recovery.Recovery_ID = V_Recovery_ID
    And Settlement.Settlement_id = Recovery.Settlement_id
    And Recovery.Amount < 0
    And Recovery.Recovery_id = Recovery_detail.Recovery_id(+)
    And Recovery.Recovery_Transaction_Internal in ('04', '17', '15') /*SWL 10/05/04 #63919*/--*009* added 15
    Group by Recovery_Detail.recovery_id;
    -- Group by Recovery_Detail.Fees_Percent; /* SWL 04/01/04 52653 */
    CURSOR Recovery_NonFEE_Negative IS
    Select Sum(NVL(Recovery_Detail.Fees, 0) + NVL(Recovery_Detail.Admin, 0)) as Total_NonCash_Fee_Negative
    From Settlement, Recovery, Recovery_Detail
    Where Recovery.Recovery_ID = V_Recovery_ID
    And Settlement.Settlement_id = Recovery.Settlement_id
    And Recovery.Amount < 0
    And Recovery.Recovery_id = Recovery_detail.Recovery_id(+)
    And Recovery.Recovery_Transaction_Internal in
    ('05', '50', '52', '51')
    Group by Recovery_Detail.recovery_id;
    -- Group by Recovery_Detail.Fees_Percent; /* SWL 04/01/04 52653 */
    --This is a generic cursor which will be used to control the number of rows inserted into the recovery_activity table
    --There has to be 1 row inserted into the recovery_activity table for each detail record in the recovery_detail table.
    --However, if no recovery_detail record exists there will be only 1 insert into the recovery_activity table.
    CURSOR Control_Detail_Loop
    IS
    Select 1
    FROM Recovery,
    Recovery_Detail
    Where Recovery.Recovery_ID = Recovery_Detail.Recovery_ID(+)
    And Recovery.Recovery_ID = V_Recovery_ID;
    /* SWL 04/01/04 Commented since the only time there were more entries in rd for a recovery is when there is a split fees */
    /* accounting does not want this to be displayed in detail. They need this aggregated as a single fee entry so the recovery */
    /* activity table will now have a single entry corresponding to each recovery in the recovery table. (#52653) */
    CURSOR Control_Detail_Loop IS
    Select 1 FROM Recovery where Recovery.Recovery_ID = V_Recovery_ID;
    /* DJ 10/25/04 # 64633 start*/
    CURSOR Event_Client_Market IS
    Select e.Client_Field_Data as Market
    From Event_Client_Field e, recovery r
    Where r.Event_ID = e.Event_ID
    AND r.Recovery_ID = V_Recovery_ID
    AND e.Client_Field_Name = 'MARKET';
    /* DJ 10/25/04 # 64633 end*/
    v_cur_day integer := 0;
    -----dj
    v_vendor_fee_wh number;
    v_total_vendor_fee_wh number;
    v_rec_itc recovery_activity.recovery_transaction_internal%type;
    --v_settlement_id settlement.settlement_id%type;
    --*004* start
    function unbundled_fee(pevent_id event.event_id%type,
    plowdate date,
    phighdate date) return number is
    -- function variables
    v_fee number(18, 2) := 0;
    v_month_revenue unbundled_recoveries.monthly_revenue%type := 0;
    v_cum_revenue unbundled_recoveries.cum_revenue%type := 0;
    v_contract_fee_per unbundled_recoveries.contractual_fee_per%type := 0;
    v_prev_cum_revenue unbundled_recoveries.cum_revenue%type := 0;
    v_cum_ub_rec unbundled_recoveries.cum_ub_recoveries%type := 0;
    v_cum_inv_paid unbundled_recoveries.cum_inv_paid%type := 0;
    v_month_rec unbundled_recoveries.monthly_recoveries%type := 0;
    v_cum_rec unbundled_recoveries.cum_recoveries%type := 0;
    v_event_id event.event_id%type;
    begin
    --v_month_rec and v_cum_inv_paid
    begin
    select event_id,
    (select sum(r.amount)
    from recovery r
    where r.event_id = e.event_id
    and trunc(r.recovery_date) between plowdate and phighdate) as monthly_recoveries,
    -- *006* added cum_rec
    (select nvl(sum(r.amount), 0)
    from recovery r
    where r.event_id = e.event_id
    and trunc(r.recovery_date) <= trunc(phighdate)) as cum_recoveries,
    (select sum(decode(nvl(ex.client_invoice_closed, 'N'),
    'N',
    ex.paid_amount,
    ex.client_invoice_received))
    from expense ex
    where ex.event_id = e.event_id
    and upper(ex.status) = 'PAID'
    and trunc(ex.check_date) <= phighdate
    and trim(ex.orig_client_invoice_date) is not null
    and nvl(ex.client_invoice_dispute, 'Y') = 'N') as cum_invoiced_paid
    into v_event_id, v_month_rec, v_cum_rec, v_cum_inv_paid
    from event e
    where e.event_id = pevent_id;
    exception
    when no_data_found then
    v_event_id := 0;
    v_month_rec := 0;
    v_cum_rec := 0;
    v_cum_inv_paid := 0;
    when others then
    v_event_id := 0;
    v_month_rec := 0;
    v_cum_rec := 0;
    v_cum_inv_paid := 0;
    end;
    -- *007* start
    -- if event previously written to table, get values from table
    begin
    select nvl(ub.cum_revenue, 0)
    into v_prev_cum_revenue
    from unbundled_recoveries ub
    where ub.event_id = pevent_id
    and ub.month_id =
    (select max(a.month_id)
    from unbundled_recoveries a
    where a.event_id = pevent_id
    and a.month_id < to_char(v_lowdate, 'YYYYMM'));
    exception
    when no_data_found then
    v_prev_cum_revenue := 0;
    when others then
    v_prev_cum_revenue := 0;
    end;
    -- *007* end
    --v_contract_fee_per
    begin
    select nvl(max(rd.fees_percent), 0)
    into v_contract_fee_per
    from recovery_detail rd
    where rd.recovery_id in
    (select r.recovery_id
    from recovery r,
    (select a.event_id, max(amount) as amount
    from recovery a
    where a.event_id = pevent_id
    and trunc(a.recovery_date) between plowdate and
    phighdate
    group by a.event_id) max_r
    where r.event_id = max_r.event_id
    and trunc(r.recovery_date) between plowdate and phighdate
    and r.amount = max_r.amount);
    exception
    when no_data_found then
    v_contract_fee_per := 0;
    when others then
    v_contract_fee_per := 0;
    end;
    v_cum_ub_rec := nvl(v_cum_rec, 0) - nvl(v_cum_inv_paid, 0);
    if ((nvl(v_cum_ub_rec, 0) > 0) and (nvl(v_month_rec, 0) <> 0)) then
    -- latest cumulative unbundled recoveries > 0
    v_cum_revenue := round(((v_contract_fee_per / 100) * v_cum_ub_rec),
    2);
    v_month_revenue := v_cum_revenue - v_prev_cum_revenue;
    end if;
    v_fee := v_month_revenue;
    return v_fee;
    exception
    when others then
    raise_application_error(-20106,
    substr('populate_recovery_activity.undebundled_fee: ' ||
    Sqlcode || Sqlerrm,
    1,
    500));
    return v_fee;
    end;

  • Help:Unable to get the Current Month Data

    Hello Folks,
    Hello Folks i have this scenario where i need to modify this code so that it has to return data from the Current month First Day to the previous Day if its a daily report and previous month data if its a monthly report.
    BEGIN
    if v_lowdate is null or v_highdate is null then
    select to_number(to_char(sysdate, 'DD')) into v_cur_day from dual;
    if v_cur_day < 25 then
    -- this is for the previous month run
    Select Add_Months(trunc(sysdate, 'MONTH'), -1)
    INTO V_LOWDATE
    FROM DUAL;
    SELECT Last_Day(ADD_Months(Sysdate, -1)) INTO V_Highdate From Dual;
    else
    -- this is for the current month run
    Select trunc(sysdate, 'MONTH') INTO V_LOWDATE FROM DUAL;
    SELECT Last_Day(Sysdate) INTO V_Highdate From Dual;
    end if;
    end if;
    I have replaced the above code with the code below but its still returning the previous month Data. Any help would be appreciated.
    v_lob := get_admin_value(p_admin_procedure_name => 'CLIENT_DATAFEED_CODE',p_err_msg => v_error_text);
    if v_lowdate is null or v_highdate is null then
    v_cur_day := TO_CHAR (SYSDATE, 'DD');
    IF report_type = 'D' -- Daily report
    AND v_cur_day > '01' -- (except when run on 1st of the month)
    THEN -- will cover from
    v_lowdate := TRUNC (SYSDATE, 'MONTH'); -- 1st of this month to
    v_highdate := TRUNC (SYSDATE - 1); -- yesterday
    ELSIF report_type = 'M' -- Monthly report
    OR ( report_type = 'D' -- (or Daily report
    AND v_cur_day = '01' -- if run on the 1st of the month)
    ) -- will cover from
    THEN
    v_lowdate := ADD_MONTHS ( TRUNC (SYSDATE, 'MONTH')
    , -1
    ); -- 1st of last month
    v_highdate := TRUNC (SYSDATE, 'MONTH') - 1; -- last day of last month
    END IF;
    END IF:

    How are you testing this? It works for me, or at least generates the dates I think you want.
    SQL> var fake VARCHAR2(25);
    SQL> var report_type VARCHAR2(1);
    SQL> exec :fake := '16-oct-2009'; :report_type := 'M';
    PL/SQL procedure successfully completed.
    SQL> DECLARE
      2     v_cur_day  VARCHAR2(2);
      3     v_lowdate  DATE;
      4     v_highdate DATE;
      5     fake_date  DATE := TO_DATE(:fake, 'dd-mon-yyyy');
      6  BEGIN
      7     v_cur_day := TO_CHAR (fake_date, 'DD');
      8     IF :report_type = 'D' AND v_cur_day > '01' THEN
      9        v_lowdate := TRUNC (fake_date, 'MONTH'); -- 1st of this month to
    10        v_highdate := TRUNC (fake_date - 1); -- yesterday
    11     ELSIF :report_type = 'M' OR (:report_type = 'D' AND v_cur_day = '01') THEN
    12        v_lowdate := ADD_MONTHS ( TRUNC (fake_date, 'MONTH'), -1); -- 1st of last month
    13        v_highdate := TRUNC (fake_date, 'MONTH') - 1; -- last day of last month
    14     END IF;
    15     DBMS_OUTPUT.Put_Line('Low: '||TO_CHAR(v_lowdate, 'dd-mon-yyyy'));
    16     DBMS_OUTPUT.Put_Line('High: '||TO_CHAR(v_highdate, 'dd-mon-yyyy'));
    17  END;
    18  /
    Low: 01-sep-2009
    High: 30-sep-2009
    PL/SQL procedure successfully completed.
    SQL> exec :report_type := 'D';
    PL/SQL procedure successfully completed.
    SQL> /
    Low: 01-oct-2009
    High: 15-oct-2009
    PL/SQL procedure successfully completed.
    SQL> exec :fake := '01-oct-2009';
    PL/SQL procedure successfully completed.
    SQL> /
    Low: 01-sep-2009
    High: 30-sep-2009
    PL/SQL procedure successfully completed.John

  • Get data for current month in VC from query - Urgent

    Hi all,
    I have designed a query for cube FIAR_C03 for overdue items and query output contains customer, net due date, document date, fiscal year period and amount. I want a chart for that query in VC that only contains those items in which net due date is in current month. How can i do that?
    Where I can place the condition to display only those items in vc in which net due date is in current month and how ?
    Please respond.
    Regards,
    Aisha Ishrat
    ICI Pakistan Ltd.

    Hi Aisha,
    It is possible to do with following steps:
    1. In Query Design make your field 'Net Due' filter with variable for date input (0CALMONTH for example where your date should be this format MMYYYY). Test your query and see if you input a month/year date it would would work;
    2. Build one table from output of your query (choose fields);
    3. In Visual Composer, drag your query into your board and from 'Varaiables' port  (NOT FROM INPUT) drag a line to create a Start point. As soon you realease to create 'Start' a box will ask which fields you want. Choose your date as field;
    4. Select the line between Start point a query. In Input Field assigned the following formula (DSTR(NOW(),'MMYYYY') *
    5. Deploy your model
    at this formula I said: transform NOW(), current date, in Text with format MMYYYY (012002 for example).
    It works!
    Assigned points if was helpful.
    Kind Regards,
    Gilson Teixeira

  • How to get the current month starting date and ending date by default ?

    Hello Creators,
    This is my requirement, kindly do the needful, Please dont gimme any links i've no access for other sites, gimme the right solution.
    My Requirement :
    Creation Date (VBAK-ERDAT) - Select Option. By default, the program should run for the current Month ie between the starting and ending date of the current month when the program is run. Today the date is 18th using sy-datum we can bring the current date by calling it in the initialization event, but the requirement is it should not give me the current date, it should only give me the month starting date and the end date. Kindly help.
    Thanks in advance ...

    DATA: gv_datum LIKE vbak-erdat.
    SELECT-OPTIONS: so_date FOR gv_datum.
    INITIALIZATION.
      CALL FUNCTION 'HR_JP_MONTH_BEGIN_END_DATE'
        EXPORTING
          iv_date             = sy-datum
        IMPORTING
          ev_month_begin_date = so_date-low
          ev_month_end_date   = so_date-high.
      so_date-option = 'BT'.
      APPEND so_date.
    START-OF-SELECTION.
    Hope this solves the issue. Don't forget to be generous
    Cheers,
    Sougata.

  • Delete DSO data for current month on a daily basis.

    Hi Gurus,
    We have a requirement where we have to delete the data in the BW DSO's for the Current Month every day before loading data into it. The reason for this is that in R3 they delete data for the current month in addition to adding new records and changing existing records. Since we do a Full load in BW, the deleted records in R3 will still exist in the BW DSO, hence the need for deletion.
    We can't delete ALL the data in the DSO as we use the BW DSO for Archiving purpose and the R3 table at any point of time will have just 3 months of data, while BW will have historical data.
    I know there is a process to delete DSO contents in the Process Chain, but can it be set up to just delete the current months data??
    Thanks
    Arvind

    Hi Arvind,
    The program RSDRD_DELETE_FACTS or transaction DELETE_FACTS will help you in deleting the records. Execute the program and select the option 'Generate Selection Program'. It will create a Z program , you can then dynamically select the current month in the Variant and assign the Z program and the variant in ABAP step of the process chain.
    Hope this helps with your requirement.
    Regards,
    BINETWEAVER2004s

  • Can one Crystal Report could contian Current Month, YTD and ITD data?

    Hi,
    I am trying to build a crystal report and be able to show data in summarized format on single report containing data for the current month, year to date and Inception to date.
    The difficulty that I find is the date ranges. Current month date range is different from YTD and ITD date.
    what would be the best way to show such data on crystal report? is there a sample report available that can help me to produce such report?
    your help will be highly appreciated, thanks!
    regards,
    Mansoor

    Hey Joe,
    if you have CRXI, take a look at the sample reports
    Record Selection on Date Range has some good examples
    you can do this with multiple Groups
    create a formula
    in to currentdate
    ( this group will cover your inception date to currentdate)
    second group will be a date group also, select year as your print by option for this group.
    3rd group also by date,
    select month.
    add fields to your details section, select the field, right click and select summary location,
    (add to all groups)
    you can then supress footers and headers as needed.
    Hope this helps.

  • Get all the back schedule start date except last and current month

    Hi All;
    Below gives me last month  schedule start
    scheduledstart >= DATEADD(mm,DATEDIFF(mm,0,GETDATE())-1,0)
    AND scheduledstart < DATEADD(mm,DATEDIFF(mm,0,GETDATE()),0)
    Below gives me current month  schedule start
    scheduledstart >= DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()), 0)
    AND scheduledstart < DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE())+1, 0)
    I need to find all the schedule start excluding current month and last month
    Any help on this much appreciated
    Thanks
    Pradnya07

    Hi,
    You could use NOT BETWEEN with the start date of last month and the end date of the current month:
    AND schedulestart NOT BETWEEN DATEADD(mm,DATEDIFF(mm,0,GETDATE())-1,0)
    AND DATEADD(MONTH, DATEDIFF(MONTH,
    0, GETDATE())+1,
    0)
    Hope this helps,

  • How to find First Program run in the Current Month in Foreground?

    Dear Experts,
    My requirement is that i need to find the First Program run date in the Current Month in foreground. The user must be allowed to run the Report only once for a month and if the next time he runs in the same month, it should not allow him to do so.
    Is there any Function Modules available? How to achieve this?
    Regards,
    Ramesh Manoharan

    Hello Ramesh,
    May be you can try with this code:
    INITIALIZATION.
      DATA:
      v_date TYPE datum,
      wa_indx TYPE indx.
    * Import the date to INDX table
      IMPORT date = v_date
        FROM DATABASE indx(xy)
        TO   wa_indx
        CLIENT sy-mandt
        ID 'DATE'.
      IF v_date IS NOT INITIAL.
        IF v_date+0(6) = sy-datum+0(6). "Check YYYYMM is same
          "Give your error message & exit
        ELSE.
          v_date = sy-datum.
    *     Export the date to INDX table
          EXPORT date = v_date
            TO DATABASE indx(xy)
            FROM   wa_indx
            CLIENT sy-mandt
            ID 'DATE'.
        ENDIF.
      ELSE.
        v_date = sy-datum.
    *   Export the date to INDX table
        EXPORT date = v_date
          TO DATABASE indx(xy)
          FROM   wa_indx
          CLIENT sy-mandt
          ID 'DATE'.
      ENDIF.
    Hope this is of some help.
    BR,
    Suhas

Maybe you are looking for

  • Wacom Tablet Mapping Bug Only in Photoshop

    I am using a Graphire Wireless Wacom Tablet on a Windows 7 PC at work. I installed the most recent drivers, and it works flawlessly in a duel monitor setup, and I have no trouble mapping it however I would like. This is all great until I launch Adobe

  • How to tally P&L YTD data with R/3

    Dear Friends, Daily we are loading data 0FI_GL_4 data source to GL cube. In GL two types accounts available. 1.Balance sheet items. 2.P&L items. Balcne sheet items allways carry foward the last years balacne.So my closing balance is tallying with R/3

  • Media center problem with Qosmio G35-650 - error message

    hello all I have a problem with media center on qosmio g35-650. When starting live tv , an error message appears and writes "application failure please restart your computer again. if problem persists again please contact with your hardware assistanc

  • My sound won't work, how do i fix it if I've already tried the audio MIDI setup?

    So i plugged in a stereo system and when i unplugged it the sound won't work anymore unless it's plugged in? How do i fix it?

  • Retain session in java client , which invokes a dotnet webservice

    Hello Forum, I am invoking a dotnet webservice using a java client. But I am not able to maintain session in this java client. I googled this, I got many links for the above. But none of the solution was using pure sun api's. My need is to do the sam