Getting Number of days full month in a selected period

Now I want to know the Total number days full months in a selected time period.
select period 1/02/2014 to 15/03/2014 ->28+31=59
count
(Descendants(
[Время].[Год-Месяц-День].CurrentMember,
[Время].[Год-Месяц-День].[Дата])) ->YMD-> 2014-365, 02-28,03-31
How to achieve aggregation of the year
59 days?

VBA!DATEDIFF("d",[Time].[Y-M-D].CurrentMember,[Time].[Y-M-D].[date].membervalue)
Does not work, gives an error
CellOrdinal 0
VALUE Error Number Query (3,
1) Function MEMBERVALUE waits for
argument 1 expression element.
Expression levels were used.
Query (1, 32) Runtime Error managed stored
procedures DATEDIFF: Microsoft :: AnalysisServices :: AdomdServer :: AdomdException.
FORMATTED_VALUE Error Number Query (3, 1)
function waits for the argument MEMBERVALUE
1 expression element. Expression
levels were used. Query (1, 32) Runtime Error
managed stored procedures DATEDIFF: Microsoft :: AnalysisServices :: AdomdServer :: AdomdException.
DATEDIFF used VBA function?

Similar Messages

  • I want to get number of days in the month I've chosen from Timeline slicer.

    I want to get number of days in the month
    I've chosen from Timeline slicer,
    does anyone know how to do?
    The problem I want to solve is to divide
    the number of customer visits as a salesman
    made during a month by the number of
    days in the month.

    Excel 2013 Pro Plus with PowerPivot.
    Count working days per month
    considering weekends and holidays.
    With help from book:
    "Building Data Models with PowerPivot"
    by Alberto Ferrari and Marco Russo.
    Easy. Not.
    http://www.mediafire.com/view/rw78t1y3bg8vm0c/04_10_15.xlsx

  • How do you show the number of days per month?

    How do you show the number of days per month?
    I am working on a budget.  I want to know how much to amortize each month to fund an investment.  Income comes monthly, but expenses leave in days, or weeks.  The number of days and weeks in months vary. 
    I want to figure out income and expenses per day, per month and per year, so I know how much can be invested each month, week or day.  For a start I would like a formula that shows how many days are in each month?

    thanks..
    I solve my problem as
    public class MyExample {
        public static void main(String a[]) {
            String stdate = "2009-03-01";
            java.sql.Date currentDate = new java.sql.Date(System.currentTimeMillis());
            java.sql.Date preDate = java.sql.Date.valueOf(stdate);
            System.out.println(currentDate);
            System.out.println(preDate);
    //        int dateCom = preDate.compareTo(currentDate);
    //        System.out.println(dateCom);
            long diff = currentDate.getTime() - preDate.getTime();
            int days = (int) Math.floor(diff / (24 * 60 * 60 * 1000));
             System.out.println(days);
    }

  • Create a field routine to calculate the number of days per month

    Hi Experts,
    I need to create a field routine to count the number of days per month based on 0CALMONTH. Could you give me some inputs on how to do it?
    Thanks!

    Hi,
    Create InfoObejct and then insert it in InfoSource/InfoCube/DSO then write simp,e code for that based on your  0CALMONTH values.
    You just copy and pas this in SE38 and see the result and implement for your requirements.
    REPORT  ztest1.
    Data: zsydt type sy-datum,
          zd(2) type n,
          zm(2) type n,
          zy(4) type n,
          zcmnth TYPE /bi0/oicalmonth,
          znds TYPE /osp/dt_day.
          zsydt = sy-datum.
          zd = '01'.
          zm = zsydt+4(2).
          zy = zsydt+0(4).
          CONCATENATE zy zm zd INTO zsydt.
          CALL FUNCTION '/OSP/GET_DAYS_IN_MONTH'
                EXPORTING
                  iv_date = zsydt
                IMPORTING
                  ev_days = znds.    "No.of days in month.
          write:/ zd.
          write:/ zm.
          write:/ zy.
          write:/ zsydt.
          write:/ znds.
    Thanks
    Reddy

  • How do i get number of days between 2 dates?

    How do i get number of days between 2 dates?
    and the result must be in int.
    for example
    Ex. startdate: 2006-06-01 enddate: 2006-06-30 and the result is: 30
    how to do so? thx

    mel
    Iv'e used this method. It assumes startdate,enddate and days have been defined before but you could pass them as args.
    void days()
        try
          Date d1 = DateFormat.getDateInstance().parse(startdate);
          Date d2 = DateFormat.getDateInstance().parse(enddate);
          long days = (d2.getTime()-d1.getTime())/1000/60/60/24;
          days = ""+days;
        catch (ParseException e)
          System.out.println("Invalid date format");
      }It actually gets the duration in ms and divides down to days.
    Regards
    Chris

  • How  can I get number of days between 2 dates ?

    How can I get number of days between 2 dates ?
    Give me answer as soon as possible.....

    Mukesh_Prajapat wrote:
    How can I get number of days between 2 dates ?
    Give me answer as soon as possible.....Is google broken again?
    [How To Ask Questions The Smart Way|http://www.catb.org/~esr/faqs/smart-questions.html]

  • How can i get number of days between two dates represented by two dates?

    how can i get number of days between two dates represented by two date objects. One is java.sql.Date, the other is java.util.Date?

    tej_222 wrote:
    But how do I do that conversion. from java.sql.date and java.util.date to calender?
    -thanks for the quick response.You may find the following utility code samples useful:
    [http://balusc.blogspot.com/2007/09/calendarutil.html]
    [http://balusc.blogspot.com/2007/09/dateutil.html]
    ganeshmb wrote:
    (date1.getTime() - date2.getTime())/(1000*60*60*24) should do.
    getTime returns millsecond value of date object and the difference divided by no of milliseconds in a day should fetch you the difference in terms of days.This doesn't respect the DST. Use java.util.Calendar.

  • Sql query to get number of days monthwise

    Hi,
    i am new to sql, can anyone please tell me query to find number of working days between two dates month wise.
    say
    firstdate last date
    21/03/2011 25/06/2011
    march april may june
    9 22 23 18

    Hi,
    918373 wrote:
    even a result like,
    stud_id month amount
    1234 MAR-11 xyz
    1234 JUL-11 ...Please post the exact output that you want.
    Do you want 'xyz' in the output, or do you want a number like 42 (2 hours * 6 weekdays in March 2011, plus 5 hpours * 6 weekdays = 12 + 30 = 42)?
    If you want 42, then post 42. Spend 5 minutes (if it comes to that much) with a calendar and a calculator to get the exact results you want.
    >
    >
    is much better,
    in that case i want it as a view, so that i can get further details from the view....Substituting your table and column names, into the query I posted earlier and replacing COUNT (*) with SUM (no_of_hours), the query is
    WITH     cntr     AS
         SELECT     LEVEL - 1     AS n
         FROM     (
                  SELECT  MAX (enddate - startdate)     AS days_in_range
                  FROM    class_dets
         CONNECT BY     LEVEL     <= 1 + days_in_range
    SELECT       x.stud_id
    ,       TO_CHAR ( TRUNC (x.startdate + c.n, 'MONTH')
                , 'fmMonth YYYY'
                )               AS month
    ,       SUM (no_of_hours)          AS total_hours
    FROM       class_dets  x
    JOIN       cntr        c  ON   x.enddate >= x.startdate + c.n
    WHERE       TO_CHAR ( x.startdate + c.n
                  , 'DY'
                , 'NLS_DATE_LANGUAGE=ENGLISH'     -- If necessary
                )      NOT IN ('SAT', 'SUN')
    GROUP BY  x.stud_id
    ,            TRUNC (x.startdate + c.n, 'MONTH')
    ORDER BY  x.stud_id
    ,            TRUNC (x.startdate + c.n, 'MONTH')
    ;The output, with the sample data you posted, is:
    `  STUD_ID MONTH                                     TOTAL_HOURS
          1234 March 2011                                         42
          1234 April 2011                                        147
          1234 May 2011                                          154
          1234 June 2011                                         154
          1234 July 2011                                          72
          1234 August 2011                                        46
          1234 September 2011                                     14
          1235 June 2011                                          36
          1235 July 2011                                          84
          1235 August 2011                                        92
          1235 September 2011                                     88
          1235 October 2011                                       12
          1236 June 2012                                          56
          1236 July 2012                                         154
          1236 August 2012                                        14Aside from pivoting, is that what you want?
    i edited the your query,
    WITH     all_dates     AS
         SELECT     start_date + LEVEL - 1     AS a_date
         FROM     (
                   SELECT     TO_DATE ((select startdate from class_dets where stud_id=1236), 'DD/MM/YYYY')     AS start_date
                   ,     TO_DATE ((select enddate from class_dets where stud_id=1236), 'DD/MM/YYYY')     AS end_dateInstead of the 2 lines above, the query I posted had
    SELECT  MAX (enddate - startdate)     AS days_in_rangeWhy did you make that change?
    The first argument to TO_DATE is supposed to be a string. You're calling TO_DATE with this as the first argument
    (select startdate from class_dets where stud_id=1236)which is a DATE, not a string.
                   FROM     dual
         CONNECT BY     LEVEL     <= end_date + 1 - start_date
    SELECT     TO_CHAR ( TRUNC (a_date, 'MONTH')
              , 'fmMonth YYYY'
              )               AS month
    ,     COUNT (*) * (select fee from class_dets where stud_id=1236) * (select no_of_hours from class_dets where stud_id=1236)               AS amount
    FROM     all_dates
    WHERE     a_date - TRUNC (a_date, 'IW')     < 5
    GROUP BY TRUNC (a_date, 'MONTH')
    ORDER BY TRUNC (a_date, 'MONTH')
    it works very well, but instead of specifying stud_id as 1236,
    but when i say,
    WITH     all_dates     AS
         SELECT     start_date + LEVEL - 1     AS a_date
         FROM     (
                   SELECT     TO_DATE ((select startdate from class_dets where stud_id=cd.stu_id), 'DD/MM/YYYY')     AS start_date
                   ,     TO_DATE ((select enddate from class_dets where stud_id=cd.stud_id), 'DD/MM/YYYY')     AS end_date
                   FROM     dual
         CONNECT BY     LEVEL     <= end_date + 1 - start_date
    SELECT     cd.stud_id,TO_CHAR ( TRUNC (a_date, 'MONTH')
              , 'fmMonth YYYY'
              )               AS month
    , count(*)
    ,     COUNT (*) * (select fee from class_dets where stud_id=1236) * (select no_of_hours from class_dets where stud_id=1236)               AS amount
    FROM     all_dates,class_dets cd
    WHERE     a_date - TRUNC (a_date, 'IW')     < 5
    GROUP BY TRUNC (a_date, 'MONTH'),cd.stud_id
    ORDER BY TRUNC (a_date, 'MONTH'),cd.stud_id
    i get error
                   SELECT     TO_DATE ((select startdate from class_dets where stud_id=cd.stu_id), 'DD/MM/YYYY')     AS start_date
    ERROR at line 6:
    ORA-00904: "CD"."STU_ID": invalid identifierThere's no column called stu_id in class_dets. There is a column called stud_id (with 2 'd's).
    >
    what should i do?
    (sorry about the query format...how display query in a formatted way? )This site noramlly compresses whitespace.
    Whenever you post formatted text (including, but not limited to, code) on this site, type these 6 characters:
    \(small letters only, inside curly brackets) before and after each section of formatted text, to preserve spacing.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to get "Number of days" in a report on 0PM_DS02

    Dear BI Gurus,
    I need to build  a query on the PM DSO - 0PM_DS02 (MTTR/MTBR).
    The query has 0Equipment in the rows
    The fields Available Time | Breakdown TIme | Utilised Time in the columns for the time granularity selected.
    The field Breakdown Time is the calcaulted key figure Actual Outage Time from the DSO.
    The field Utilised Time  is a formula = Available Time - Breakdown Time.
    The issue I am facing is regarding the field Available Time.
    In the report the user needs time granularity in Month and Year.
    Basically the logic for the field Available Time = Number of days in the time period selected * 24
    where 24 = number of hours in a day.
    Now my issue is when the time granularity is month , the field should have the number of days in the month the user selects from the selection screen and when the time granularity is year, the field should have number of days in that year.
    Also during the query execution period, when the user changes the time granularity the report should also change the calculation for this field.
    (I can bring an extra field to the DSO, which will bring the available number of days in a month for each record)
    Can you please guide me how to map this scenario.
    Many Thanks in Advance,
    With Warm Regards,
    Vineeth

    Hi All,
    Waiting for your suggestion on this?
    With Warm Regards,
    Vineeth

  • Getting number of days between 2 dates

    Hello All,
    I require the number of days between 2 dates.
    The number of days is between low date : PR Date (not an input variable) and the high date.
    I have created an customer exit variable to get sy-datum in made it as formula variable.
    I have also created a formula variable for PR Date , and subtracted the 2 dates.
    It is not giving the correct result.
    Any suggestions.
    Thanks & Regards,
    VL

    Read through this web link.  It will show you how to calculate the days between 2 dates directly in your BEX query.
    No exit needed to calculate this.
    http://teklink.co.uk/sap/sap-bi-bw-how-to-use-replacement-path-variables-to-perform-date-calculations-in-the-bex-analyzer/

  • MDX- Getting Number of days in a selected period

    HI All,
    I need a help in MDX.
    Here I am calculating the number of days in a selected time period.
    In my date dimension we have the Month as the last level.
    But somehow I bring a column called "Days in Month" 
    Now my Date dimension table is like below:
    Id   year  Month
    DaysInMonth
    1 2014
    Jan 31
    2  2014
    Feb 28
    12  2014
    Dec 31         and so on.....
    So i created a hierarchy which contains three levels i.e. Year--->Month---->---->DaysInMonth
    Now I want to know the Total number of days in a selected time period.
    i.e. if I select 2014 then it should show 365, similarly if i select
    Aug-2014 then it should show 31.
    I have tried the below code i.e. 
    WITH MEMBER measures.X AS
          count( DESCENDANTS (
                [Time Accounting period].[Hierarchy].CURRENTMEMBER,
                [Time Accounting period].[Hierarchy].[Days In Month]))
    SELECT Measures.X ON 0,
    [Time Accounting period].[Hierarchy].[Year].&[2013] on 1 
    FROM [XXX]
    Here it is showing me the total members in that particular level,
    E.g. When I am selecting 2013, its showing me 12
    If I select Jan-2013, its showing me 1
    But I dont want this, if I would have the Dates in my Date Dimension, then this code would have worked perfectly.
    So i just want to know if somehow we can use the DaysInMonth
    column to accomplish this.
    Thanks
    Sudipta Ghosh
    Sudipta Ghosh Tata Consultancy Services

    HI David,
    If I would have the Day level data then my below code will give me the desired result.
    WITH MEMBER measures.X AS
          count( DESCENDANTS (
                [Time Accounting
    period].[Hierarchy].CURRENTMEMBER,
                [Time Accounting
    period].[Hierarchy].[Days]))
    SELECT Measures.X ON 0,
    [Time Accounting period].[Hierarchy].[Year].&[2013]
    on 1 
    FROM [XXX]
    But unfortunately I don't have the Day level in the dimension, So was wondering whether we can use the
    DaysInMonth column by any means.. :(
    Sudipta Ghosh Tata Consultancy Services

  • How to get the last day of the current open fiscal period?

    hi folks,
         I  have to display the last date of the current open fiscal period in the selection screen. Its just a display only.
          if there is any function module vailable for getting that period, kindly suggest me?
    thanks in advance,
    cheers,
    Adi.

    hi,
    CALL FUNCTION '/BEV3/CHPERIOD_DETERMINE'
    EXPORTING
    date = sy-datum
    version = c_version
    IMPORTING
    period = l_period
    year = l_fiscal_year
    EXCEPTIONS
    period_in_not_valid = 1
    period_not_assigned = 2
    version_undefined = 3
    OTHERS = 4.
    If not use GM_GET_FISCAL_YEAR
    CALL FUNCTION 'GET_CURRENT_YEAR'
    EXPORTING
    BUKRS = '1000' " Company Code
    DATE = SY-DATUM " Date to find fiscal year for
    IMPORTING
    CURRM = w_currm " Current Fiscal Month
    CURRY = w_curry " Current Fiscal Year
    PREVM = w_prevm " Previous Fiscal Month
    PREVY = w_prevy. " Previous Fiscal Year
    Rgds
    Anver

  • SSAS Tabular - return number of days in given month using month's start date?

    Is there a way to return the number of days in a month by providing just the month date or month start date?
    We have a time table, but it is at monthly (not daily) granularity.
    So I can't just count rows between start/end of month.
    I need to be able to divide by the number of days in a given month and can't seem to find a way to get number of days in that given month.
    Thanks!

    Hi,
    According to your description, you want to get the number of days in a month with the month's start date, right?
    In this case, we can get the first day of next month using DateAdd function, and then use DateDiff function to calculate the number of days in this month. Here is a sample query for your reference.
    WITH
    MEMBER Measures.Today AS vba!Now()
    member measures.FirstDayOfNextMonth as dateadd("m",1,Measures.Today)
    member measures.daysnumber as datediff("d",Measures.Today,measures.FirstDayOfNextMonth)
    select Measures.daysnumber on 0
    from
    [Adventure Works]
    Reference
    http://msdn.microsoft.com/en-us/library/hh510163.aspx
    http://office.microsoft.com/client/helppreview14.aspx?AssetId=HV080007558&lcid=1033&NS=EXCEL%2EDEV&Version=14&tl=2&pid=CH080007543
    http://office.microsoft.com/client/helppreview14.aspx?AssetId=HV080007559&lcid=1033&NS=EXCEL%2EDEV&Version=14&tl=2&pid=CH080007543
    Regards,
    Charlie Liao
    TechNet Community Support

  • Customer Exit to get last day of month from Year/month

    Hi Experts,
    I need to create a customer exit to get the last day of month from Cal Year month input variable.
    Examples
    1)
    User input period: 12.2008
    I need from the customer exit: 31.12.2008
    2)
    User input period: 02.2009
    I need from the customer exit: 28.02.2009
    Can someone help me with the ABAP code to achieve this with a customer exit?
    Help will be appreciated.

    Hi,
    Please use the following code,
    Second one is the suitable solution for you, I can understand that, if it leafe year then you have the problem so use the secon one.
    First one is using Period i.e. 010.2008 (December 2008).
    Secodn one is based on Date/Month.
    Note: Insted of SY-DATUm, you give your variable name
    *******To get the Last day of the Fy Period entered by User in ZFYP***
        WHEN 'ZLDAY_FI'.
          LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = 'ZFYP'.
            zbdatj = loc_var_range-low+0(4).
            zbuper = loc_var_range-low+4(3).
            CALL FUNCTION 'LAST_DAY_IN_PERIOD_GET'
              EXPORTING
                i_gjahr = zbdatj
                i_periv = 'V3'
                i_poper = zbuper
              IMPORTING
                e_date  = zzdate.
            CLEAR: l_s_range.
            l_s_range-low = zzdate.
            l_s_range-sign = 'I'.
            l_s_range-opt = 'EQ'.
            APPEND l_s_range TO e_t_range.
          ENDLOOP.
    Note: in the below code I given SY-DATUM, so you change to your Month Variable like using  
    LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = 'XXXX'.
    ** Last Day of Current Calendar month
          zzdate = sy-datum.
          CALL FUNCTION '/OSP/GET_DAYS_IN_MONTH'
            EXPORTING
              iv_date = zzdate
            IMPORTING
              ev_days = znum.
          CLEAR: l_s_range.
          l_s_range-low+6(2) = znum.
          l_s_range-low+0(4) = sy-datum+0(4).
          l_s_range-low+4(2) = sy-datum+4(2).
          l_s_range-sign = 'I'.
          l_s_range-opt = 'EQ'.
          APPEND l_s_range TO e_t_range.
    Thanks
    Reddy
    Edited by: Surendra Reddy on Jan 27, 2009 2:47 PM
    Edited by: Surendra Reddy on Jan 28, 2009 6:12 AM

  • Is it posible to get how many day's has one specific month with Calendar

    Can any help me how to get how many days one month has. Like february 28, and sometimes 29.

    There is no way to do this within Calendar directly, the Gregorian calendar has a private method that does this, shame its not public.
    You would need to do something like,
    import java.util.*;
    public class MyCalendar extends GregorianCalendar {
        private static final int MONTH_LENGTH[]
            = {31,28,31,30,31,30,31,31,30,31,30,31}; // 0-based
        private static final int LEAP_MONTH_LENGTH[]
            = {31,29,31,30,31,30,31,31,30,31,30,31}; // 0-based
        /** Creates a new instance of MyCalendar */
        public MyCalendar() {
        public final int monthLength(int month, int year) {
            return isLeapYear(year) ? LEAP_MONTH_LENGTH[month] : MONTH_LENGTH[month];
        public static void main(String argv[]){
            MyCalendar cal = new MyCalendar();
            System.out.println( "There are " + cal.monthLength(cal.get(Calendar.MONTH),cal.get(Calendar.YEAR)) + " days this month.");
    }

Maybe you are looking for

  • Changing the sender name of WF-BATCH

    Hi, I am new to workflow programming and looking for guidance on changing the sender name of the emails going (SENDMAIL activity) as WF-BATCH user. I looked at the input from this group on similar question and understood that what I need to achieve c

  • Bluestacks displays an error with Graphics card while installing

    My laptop is a DV6 6121tx with product number QB367PA#ACJ. While installing bluestacks, it displayed an error stating not able to recognise the graphics card in the system. Please suggest a safe update for the ame if available. HP support assistant d

  • PAL & NTSC importing

    I've had no problems importing video until I changed the iMovie preferences to import PAL video at 25fps. When I switched the preferences back to NTSC 30fps, quit iMovie then came back in, I can no longer import the NTSC video as before. The audio is

  • Regarding Delivery and HU

    Hi All, I have an requirement related to delivery. When HU is assigned to delivery, tear weight of the HU needs to be added with gross weight. Can any one please explain where I can write the code. I am facing problems in getting HU data in to any of

  • Time Machine over network: can't see hard drive

    I've connected an external firewire 800 drive to our server and then chosen it in Server Preference as a drive that users can backup to, however when I try to select it in the user's Time Machine prefs I can't see the drive. Any ideas?