Previous Month Customer Count

Hi all,
I hope you can help me with my little problem.
I am using BI version 11.1.1.6.5 and would like to create a report, where there are going to be two columns (along with a number of others):
1. Number of customers for the selected month (using a dashboard prompt)
2. Number of customers for the month before the one selected above
It is easy to create #1 with COUNT(DISTINCT "Dim Sender Customer V"."Sender Customer Id"). I'm not sure how I can create #2... any ideas?
Regards,
Cihan

You can find previous row measure value using MSUM function.
MSUM("Sales Facts"."Amount Sold",2) - "Sales Facts"."Amount Sold"
Replace "Sales Facts"."Amount Sold" with your measure and make sure your report is properly sorted by Month.
Thanks
Edited by: Maqsood Hussain on Dec 6, 2012 11:35 PM

Similar Messages

  • Calculating count during previous months

    I am working on a report where we need to track the number of tickets that were open at the end of previous months. I have calculated those tickets that were closed in the same month by comparing the month of the ticket's creation date with that of the ticket's close date using a CASE if:
    CASE WHEN MONTH(ticket_fact.Modified) = Month(ticket_fact.Created) THEN 0 ELSE 1 END
    How do I get just the count of all the tickets for this. I have results in a table but now each row shows a 0 or 1 and Pivot table does not seem to work as well.
    If I use Status then I get the status that the ticket is currently in.
    Thank you so much.

    OK, based on what your are asking and what you have done, I have to ask if what you are trying to do is what you really want to track. For one thing, your approach only works "this year." Once the new year comes, using the MONTH function will get you the counts of both "this year" and "last year." So counting only using the "months" of the dates is not correct. You would need the YEAR function as well.
    Second, if you want to know if tickets are being closed in a reasonable amount of time, then you don't want to track just tickets that "opened and closed in the same month." Why? Because what if a ticket opened two days before month end and closed three days later? Wouldn't that be pretty efficient? Yet your report won't track that since the created and closed dates are in different months.
    What I would suggest as a better report is to track tickets that close within certain breakpoints in time, regardless of what day of the month it opened, for example, how many tickets were closed within 30 days? How many were closed in 60 days? etc. This report would give you a better analysis than tickets opened and closed in one month.
    You would need to categorize your tickets with a CASE statement similar to the following:
    CASE WHEN TIMESTAMPDIFF(SQL_TSI_DAY, ticket_fact.Created, ticket_fact.Modified) < 30 THEN 'Less than 30 Days' ELSE CASE WHEN TIMESTAMPDIFF(SQL_TSI_DAY, ticket_fact.Created, ticket_fact.Modified) < 61 THEN '30 - 60 Days'...
    This is what you should count.

  • Previous Month, YTD, PreviousYTD counts in one report with charts

    Hello to all users,
    I am new to my current job and also to Crystal Reports. I was given the task of creating a sales summary report that has each salesman and their department and 3 different count fields of sales completed ( based on different date ranges). The 3 count fields need to be for the previous full month, YTD(current year) and then YTD ( previous year). We are running Crystal Reports 2008.
    I tried using subreports but that seemed to throw off the overall size of the report. I also tried creating a formula field that had a count as well as a date filter for each field, but that threw and error of a boolean and numeric in the same field.
    Could anyone out there tell me the best way to accomplish this report? Thanks in advance for any help or suggestions.

    This is going to be difficult, if not impossible to do with tables in Crystal.  Do you know how to write SQL?  The most efficient way to do this is going to be to write a command (SQL query).  You can do this two ways:
    1.  Write a separate command for Previous Month, YTD, and Previous YTD, each of which does the counts for that time period and then join them together based on a field that identifies the sales person.  However, if there are lots of sales people, this will be slow because Crystal will have to pull the results of all three queries into memory in order to join them together.
    2.  The best way is going to be to write a single query that pulls all of the data for your report.
    -Dell

  • Getting data in a query on last date of all previous months

    Dear Experts,
    I need your help with a query.
    I am trying to create a query which when run should pick the number of Open Sales Order on the last date of all the previous months from the start of company.
    I could create the query for fetching the required data on last day of the previous month, say today is 25th June 2014, so my query only fetches data for May 31st 2014 but I need data for all previous month, May 31st 2014, April 30th 2014, March 31st 2014 & so on.
    Please advise how to achieve this is SQL query.
    Thanks & regards,
    Nitin

    Hi,
    Try this:
    Select *
    from(
    SELECT T0.[DocNum] as #,t0.cardcode as C, t0.docdate
    FROM ORDR T0
    WHERE T0.[DocStatus] = 'o' and T0.[DocDate]  = CONVERT(VARCHAR(10), DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,getdate())-1,0)),10) OR T0.[DocDate]  = CONVERT(VARCHAR(10), DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,getdate())-2,0)),10) or T0.[DocDate]  = CONVERT(VARCHAR(10), DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,getdate())-3,0)),10) or T0.[DocDate]  = CONVERT(VARCHAR(10), DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,getdate())-4,0)),10) or T0.[DocDate]  = CONVERT(VARCHAR(10), DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,getdate())-5,0)),10) or T0.[DocDate]  = CONVERT(VARCHAR(10), DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,getdate())-6,0)),10) or T0.[DocDate]  = CONVERT(VARCHAR(10), DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,getdate())-7,0)),10)
    group by t0.cardcode,docdate,T0.[DocNum]) S
    pivot
    (count(#) for c in([cvt01],[cvt02],[cvt03],[cvt04],[cvt05],[cvt06],[cvt07],[cvt08],[cvt12])) P
    Note: Replace Cvt01,02...with your customer code.
    Thanks & Regards,
    Nagarajan

  • Previous month end based on prompted values

    Hello All,
    I need to create a SR report that shows:
    Received in current month: count of Service requests recorded in current month selected. For instance if date prompt selection was March 2010 then count of SR recorded from Mar 1- 31,2010
    Open Service Requests at month end Count of SRs where "Date Completion entered in system" is null as last day of month selected(eg March 31)
    Carry over from Previous month: same as Open Service Request as month end less one month.( eg Feb 28)
    I currently have a prompt which lets the end user choose the Month and Year they want to run the report for. I am getting the right values in my first two columns but my carry over is giving me problems. Any idea how I can write a formula for 'Carry over from Previous month'??
    Any help is appreciated!
    Sonia

    Hi Max,
    The carry over is causing problems. However, the formula for the month end chosen is
    SUM(CASE WHEN CAST ("Service Request"."Closed Date and Time" AS DATE) IS NULL OR CAST ("Service Request"."Closed Date and Time" AS DATE) > TIMESTAMPADD (SQL_TSI_MONTH, 1, (TIMESTAMPADD (SQL_TSI_DAY, - (DAYOFMONTH(CAST ("- Service Request Custom Attributes".INDEXED_DATE_0 AS DATE))), CAST ("- Service Request Custom Attributes".INDEXED_DATE_0 AS DATE))))THEN 1 ELSE 0 END)
    But when I use this formula for previous month (-1).. It does not work. It gives me zero.
    Thanks!
    Sonia

  • Display previous month value in report

    Hi,
    I have a requirement to display the previous month amounts on monthly basis. here is the example.
    In the Cube I have data like this:
    <b>Customer   Month         Amount</b>
    C1        Jan 2004        $500
    C1        Feb 2004        $600
    C1        March 2004      $1000
    I want to display in Report with another key figure to show the difference between current month and previous month. Report should look like:
    <b>Customer   Month  Amount  <i>Prev_Month_Amount     <u>Diff</u>.</i></b>
    C1      Jan 2004   $500         0               $500
    C1      Feb 2004   $600       $500              $100
    C1      Mar 2004   $1000      $600              $400
    I have tried using restricted key figures.but it is showing the same amount in prev. moth amount colunm till feb 2004. anyone had similar req. please advise me.
    Thanks in advance,
    Ram

    Hi,
    I can only think about a 2 structure approach with cell calculations.
    This will result in a static report with 12 rows for each customer. Then you would need to use the new feature of zero supression, to hide those month where no data exists.
    Heike

  • Display current and previous months records only

    Hello gang,
    My selection criteria looks like this:
    not ({HRDEPBEN.PLAN_CODE} startswith ["C", "EAP", "HMIL", "V", "W"]) and
    (month({hrdepben.Creation_date}) = month(currentdate)) and
    {HRDEPBEN.PLAN_TYPE} = "HL"
    I modified it to this in order to pull in previous month's data too:
    {HRDEPBEN.PLAN_TYPE} = "HL" and
    not ({HRDEPBEN.PLAN_CODE} startswith ["C", "EAP", "HMIL", "V", "W"]) and
    (month({hrdepben.Creation_date}) = month(currentdate) or month ({hrdepben.Creation_Date})= month (currentdate)-1)
    However, it's still pulls the same record count and only January records, not Decembers'.
    Where am I going wrong?
    Thanks

    Looks like you're reporting against Lawson?  What database are you using?
    There are a few issues with the record selection criteria as it's written:
    1)  Month(CurrentMonth) - 1 = 0 when the current month is January.  That's why your not getting any records from December.
    2)  The  monthly criteria won't be passed to the database for processing, which is a huge performance issue when you're reporting against a system like Lawson.  You're basically telling the report to bring back all records that don't start with an array of values, irrespective of the date.  Only after all the possible records are returned across the network will the extraneous records be filtered out on the client side.  That's bad.
    3)  It's easy to use StartsWith or Like, but it's also pretty inefficient, since it forces a full table scan of the underlying table
    Personally, I'd do one of two things in order to both fix the query and optimize it:
    1)  Write the underlying query in SQL as either a View or SQL Command object
    or
    2)  Keep the current report, but make use of SQL Expression fields in order to optimize the query.
    Here are some examples of SQL Expression fields against Oracle (PL/SQL) that could be useful:
    /*{%PLANCODES}*/
    /*This SQL Expression evaluates whether or not a Plan Code starts with the specified values*/
    /*"HRDEPBEN"."PLAN_CODE" is selected directly from the Field Tree in the SQL Expression Editor*/
    CASE
      WHEN SUBSTR("HRDEPBEN"."PLAN_CODE",1) IN ('C','V','W') THEN 'Y'
      WHEN SUBSTR("HRDEPBEN"."PLAN_CODE",3) = 'EAP' THEN 'Y'
      WHEN SUBSTR("HRDEPBEN"."PLAN_CODE",4) = 'HMIL' THEN 'Y'
      ELSE 'N'
    END
    /*{&CREATEDATEMONTH}*/
    /*This SQL Expression returns the month of the Creation Date field*/
    /*"HRDEPBEN"."CREATION_DATE" is selected directly from the Field Tree in the SQL Expression Editor*/
    TO_NUMBER(TO_CHAR("HRDEPBEN"."CREATION_DATE",'mm'))
    You could also create formula to return the Month value for last month and then use it in your record selection:
    //{@LASTMONTH}
    //This formula returns the Month value for Last Month
    //IIF statements can be passed to the database for processing
    IIF(Month(CurrentDate) = 1, 12, Month(CurrentDate) - 1)
    With expressions and formulas like these in place (this code is Oracle and DB2 compatible, it would be different for T-SQL), you could then modify your record selection criteria to be something simpler, like this:
    {HRDEPBEN.PLAN_TYPE} = "HL" and
    {%PLANCODES} = 'N' and
    {%CREATEDATEMONTH} IN {@LASTMONTH} TO MONTH(CURRENTDATE)// MONTH(CURRENTDATE) is passed to the DB
    By laying the groundwork, you'll have a much more efficient report and, in the case of the @LastMonth, more accurate! Hope this helps!
    p.s. a disclaimer on using SQL Expressions in this manner - it's not officially supported, although it's worked since Version 7 (when SQL Expressions were introduced) and there will be support for them in various 2011 versions. As such, they'll work for years. I use them all the time and they're fantastic for optimizing reports.

  • Need help with SQL retrieval for previous month till current date

    Hi ,
    Need help generating statistics from previous month from date of enquiry till current date of enquiry.
    and have to display it according to date.
    Date of enquiry : 03/02/2012
    Application Type| 01/01/2012 | 02/01/2012 | 03/01/2012 |...... | 31/01/2012 | 01/02/2012 | 02/02/2012 | 03/02/2012 |
    sample1 20 30 40
    sample 2 40 40 50
    sample 3 50 30 30
    Hope you guys can help me with this.
    Regards

    Hi,
    932472 wrote:
    Scenario
    1)If i run the query at 12 pm on 03/2/2012. the result i will have to display till the current day.
    2)displaying the count of the application made based on the date.
    Application type 01012012 | 02012012 | 03012012 | ..... 01022012| 02022012|03022012
    sample 1 30 40 50 44 30
    sample 2 35 45 55
    sample 3 36 45 55Explain how you get those results from the sample data you posted.
    It would help a lot if you posted the results in \ tags, as described in the forum FAQ. {message{id=9360002}
    SELECT     application_type as Application_type
    ,     COUNT (CASE WHEN created_dt = sysdate-3 THEN 1 END)     AS 01012012 (should be getting dynamically)
    ,     COUNT (CASE WHEN created_dt = sysdate-4 THEN 1 END)     AS 02022012
    ,     COUNT (CASE WHEN created_dt = sysdate-5 THEN 1 END)     AS 03022012
    , COUNT (CASE WHEN created_dt = sysdate-6 THEN 1 END)     AS 04022012
    FROM     table_1
    GROUP BY application_type
    ORDER BY     application_typeThat's the bais idea.
    You can simplify it a little by factoring out the date differences:WITH got_d     AS
         SELECT     qty
         ,     TRUNC ( dt
              - ADD_MONTHS ( TRUNC (SYSDATE, 'MON')
                        , -1
              ) AS d
         FROM table1
         WHERE     dt     >= ADD_MONTHS ( TRUNC (SYSDATE, 'MON')
                        , -1
         AND dt     < TRUNC (SYSDATE) + 1
    SELECT     SUM (CASE WHEN d = 1 THEN qty END)     AS day_1
    ,     SUM (CASE WHEN d = 2 THEN qty END)     AS day_2
    ,     SUM (CASE WHEN d = 62 THEN qty END)     AS day_62
    FROM     got_d
    See the links I mentioned earlier for getting exactly the right number of columns, and dynamic column aliases.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Previous Month, Current Month, Percent Change

    Post Author: lcrawfor
    CA Forum: Formula
    I need to create a report which shows the count of orders for the previous month, the current month and the percent change. An example follows.I suspect I need to use sql expressions but I can't figure it out. Anbody else know how to do this?Crystal Reports X1, SQL  Server 2005Orders tableCUSTNUMB       VARCHAR(15)ORDER_DATE    DATETIMEREGION             VARCHAR(10)ORDER_NUMB   INTOrders Monthly Summary ReportRegion                     2007 - 07                           2007-08                Percent ChangeEast                           3,478                                 4,568                         31%North                          2,364                                 2,578                          9%South                         7,634                                 7,189                         -6%West                         1,891                                  2,231                        18%Total                        13,665                                16,566                          21%

    Post Author: Jagan
    CA Forum: Formula
    Simplest way would be to use a Command or view to return the count grouped by region,month and just report off that.
    Another way I think will work is:
    Group on Region (group 1) then Date (group 2).
    As you've only got two months of data, presumably restricted by the record selection formula, implicitely ordered by the grouping, in the group 1 header you'll be 'looking' at the 1st month's 1st record so use a formula to calculate and store the count for the 1st month:   count({table.x}, {table.date}, "monthly")
    In group 1's footer you'll be 'looking' at the 2nd month's last record; that month's count is also  count({table.x}, {table.date}, "monthly");Suppress the details etc., print these in group 1's footer and use to calculate the %change
    Of course, this assume that there's always data for both months, but it's not too tricky to account for this if necessary.

  • Any fiscalyear select varible screen current month-previous month less all

    Hi,
    1 My requirement is end user will enter fiscal year e.g 2009-2010  (all fiscal year periods come  ) and in report my requiremnt is to
    show data
    2.  april to march
    3.  current month  minus  previous month  billing qty
    e.g    april  may june july  august ............................
    may - april billibg qty = variation
    june -may = var
    july - june ....= var
    thanks
    sai.
    Edited by: solv_ti on Jun 30, 2010 11:59 AM

    You can user customer exit to restrict the report for required month from the input year.
    Find the currect and previous month . Then you can also restrict the bill qty with the difference between current and pervious month.
    Hope this helps.

  • To display previous month's calday for current calday in report.

    Dear Experts,
    I need to build a query in which at any point of for given calday, it should produce me the previous month calday's result  in the report.
    For example i have revenue as key figure in columns. calday in rows and product details in free characteristics.
    When calday for eg. 16-04-2011 is entered , report should display  16-03-2011 revenue .
    Regards
    Alex

    Hi,
    u need to use the customer exit variable inorder to serve your purpose..
    Create a characteristic variable with Customer exit as processing type.
    Case 1: Based on System date...
    Case i_vname
    When 'ZCEXIT' ""Your Customer exit variable**.
    data: date type dats,
          l_s_range type rsr_s_rangesid.    
    Press Ctrl+F6 and provide DATE_CREATE in the Call function Radio button
    CALL FUNCTION 'DATE_CREATE'
      EXPORTING
      ANZAHL_JAHRE         = 0
      ANZAHL_KALTAGE       = 0
       ANZAHL_MONATE        = -1
      ANZAHL_TAGE          = 0
        datum_ein            = sy-datum
      DATUM_EIN_ULT        = ' '
      ULTIMO_SETZEN        = ' '
      IMPORTING
       DATUM_AUS            = Date
      E_TT                 = E_TT
      E_ULTKZ              = E_ULTKZ
    l_s_range-low =  date .
    l_s_range-sign = 'I' .
    l_s_range-opt = 'EQ' .
    append l_s_range to e_t_range.
    endcase.
    Case 2:Based on User input date...
    data:  date1 type dats,
           date2 type dats,
           loc_var_range like rrrangeexit.
    LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE WHERE VNAM = 'ZVAR1'. "Technical name of the user input variable.
    date1 = loc_var_range-low.
    Press Ctrl+F6 and provide DATE_CREATE in the Call function Radio button
    CALL FUNCTION 'DATE_CREATE'
      EXPORTING
      ANZAHL_JAHRE         = 0
      ANZAHL_KALTAGE       = 0
       ANZAHL_MONATE        = -1
      ANZAHL_TAGE          = 0
        datum_ein            = date1
      DATUM_EIN_ULT        = ' '
      ULTIMO_SETZEN        = ' '
      IMPORTING
       DATUM_AUS            = Date2
      E_TT                 = E_TT
      E_ULTKZ              = E_ULTKZ
    l_s_range-low =  date2 .
    l_s_range-sign = 'I' .
    l_s_range-opt = 'EQ' .
    append l_s_range to e_t_range.
    endloop.
    Reply me if you have further querries.
    Best Regards
    Seshu
    Edited by: seshagiri.rao on Apr 18, 2011 12:15 PM

  • Looping through a month to count the number of Mondays etc

    Can someone give me some pointers about where I'm going wrong here please? (No, this isn't a homework but I am trying to solve something). I want to be able to loop through the days in the previous month to find out how many Mondays, Tuesdays etc so that I can work out something else. Yes, I have read all the API information about Calendar,GregorianCalendar etc and I have a mental block about loops and the answer is probably very simple so please be gentle!
    import java.util.Date;
    import java.util.*;
    import java.text.*;
    class Dates
      public static void main (String [] args)
           int i;
         int mondayCount;
         int daysInMonth;
        DateFormat reportDateFormat = new SimpleDateFormat("EEEE dd.MMM.yyyy");
         Calendar theDay = Calendar.getInstance();
         theDay.add(Calendar.MONTH,-1);
         daysInMonth=theDay.getActualMaximum(theDay.DAY_OF_MONTH);
         int today = theDay.get(Calendar.DAY_OF_MONTH);
         int dayOfWeek = theDay.get(Calendar.DAY_OF_WEEK);
         mondayCount=0;
         for (i=0;i<daysInMonth;i++)
         if(today==Calendar.MONDAY)
                   mondayCount++;
         System.out.println("Testing "+mondayCount);
           System.out.println("Day of Week"+ dayOfWeek);
         System.out.println("Days in month" +daysInMonth);
         System.out.println("Today" + today);
         System.out.println("theDay"+ theDay);
      I can find out how many days are in the previous month( I think!) and what the code is for today- but what am I not getting here? My loop just gives 0 31 times.
    Any constructive help would be much appreciated.

    you were never actually updating the day of the month.... check out the updated code below....
    import java.util.Date;
    import java.util.*;
    import java.text.*;
    class tester
      public static void main (String [] args)
           int i;
         int mondayCount;
         int daysInMonth;
        DateFormat reportDateFormat = new SimpleDateFormat("EEEE dd.MMM.yyyy");
         Calendar theDay = Calendar.getInstance();
         theDay.add(Calendar.MONTH,-1);
         daysInMonth=theDay.getActualMaximum(theDay.DAY_OF_MONTH);
         int today = theDay.get(Calendar.DAY_OF_MONTH);
         int dayOfWeek = theDay.get(Calendar.DAY_OF_WEEK);
         mondayCount=0;
         theDay.set(Calendar.DAY_OF_MONTH, 1); // set the date to the 1st of the month
         for(i=1;i<=daysInMonth;i++) {          
              if(theDay.get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY) {
                   mondayCount++;
              theDay.add(Calendar.DAY_OF_MONTH, 1);
         System.out.println("Monday count = " + mondayCount);      
      }

  • 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!!

  • SSRS Expression Help, Default to Current Month UNLESS it is the First Day thru the 5th Day, then go to previous month?

    Hello,
    I need to write an expression for the default month parameter for a report.
    Report data is imported on the 5th of each month for the previous months data.
    currently my expression is this =IIf(Month(DateAdd("m",-1,today ()))
    I need an iff statement that says if todays date is 1-5 then set the default to (Month(DateAdd("m",-2,today ()))
    Ill then display a otherwise hidden text box that reads the previous months data is not availble untill after the 5th, displayed is data from 2 months ago, or something to that effect.
    Thanks.

    iif(datepart(dateInterval.Day,now()) <= 5, datepart(dateInterval.month,now()), datepart(dateInterval.month,now())-1)

  • Defining last day of previous month in ABAP

    All,
    I am a BW guy and hardly know ABAP. I have a requirement where I have to calculate last day of previous month and use it in the routines of the transformations.
    I have decided to define the Last day of previous month in Start routine and then use the global variable in Transformations to calculate further.
    The logic that i have used is outlined below.
             Define G_DATE in global declaration for further use in Transformations.
    In the Routine section,
            Assign G_DATE to SY-DATUM
            G_DATE + 6(2) = '01' (Replace last to field of date with '01' to establish first day of the current month)
            G_DATE = G_DATAE - 1 (To get to last day of previous month)
    My dilemma is to implement this in ABAP in Start routine of transformations. Please include the exact ABAP code that would be needed in Declarations and Routine section.
    Thanks in advance.

    Hi..,
    Go with the function module: LAST_DAY_OF_MONTHS
    So, Just determine the last month from the sy-datum and then use above function module and pick the last date of the month.
    Thanks,
    Naveen Inuganti.

Maybe you are looking for