Count days per month

dear members,
I have been provided with the date range.
i want to calculate the no. of days for each month, within the above date range.
e.g. date1='10-01-2011' and date2='18-03-2011'
for month=01 count days=22
for month=02 count days=28
for month=03 count days=18
thanks
teefu
developer

WITH     parameters     AS
     SELECT     TO_DATE ( '10-01-2011'
               , 'DD-MM-YYYY'
               )     AS start_dt
     ,     TO_DATE ( '18-03-2011'
               , 'DD-MM-YYYY'
               )     AS end_dt
     FROM     dual
SELECT     TO_CHAR ( start_dt + LEVEL - 1
          , 'FMMonth YYYY'
          )     AS month
,     COUNT (*)     AS days
FROM     parameters
CONNECT BY     LEVEL <= 1 + end_dt - start_dt
GROUP BY TO_CHAR ( start_dt + LEVEL - 1
          , 'FMMonth YYYY'
ORDER BY MIN (LEVEL)
duplicate thread already one has given the above answer
count days of the month
Edited by: LPS on Jul 21, 2011 2:16 AM

Similar Messages

  • 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 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);
    }

  • Count Days in month

    Hi Team members,
    we are working on a budgeting application and stuck on below Research, please assist/advise is there any built-in Function to count Days in a Month which we can use or a work around .
    Requirement:
    To calculate budgeted Expenses per month, user will enter the daily budgeted expenses for a month and it will multiple with total number of days in a month via formula. same thing happens to some revenue items.
    Note:
    every months contains different number of Days which will result in change in Expense/Revenue figures.
    e.g
    Daily Expense for Jan will be $100/day
    total days in Jan = 31
    Result will be 31*100 = $3100 expense in Jan
    but in Feb it will be
    Daily Expense for Feb will be $100/day
    total days in Jan = 28
    Result will be 28*100 = $2800 expense in Feb
    Regards,
    Alee

    Dear Alp,
    Thanks for the Code!!!
    Note:
    In general terms the algorithm for calculating a leap year is as follows...
    A year will be a leap year if it is divisible by 4 but not by 100. If a year is divisible by 4 and by 100, it is not a leap year unless it is also divisible by 400.
    Thus years such as 1996, 1992, 1988 and so on are leap years because they are divisible by 4 but not by 100. For century years, the 400 rule is important. Thus, century years 1900, 1800 and 1700 while all still divisible by 4 are also exactly divisible by 100. As they are not further divisible by 400, they are not leap years.
    Regards,
    Alee

  • Count records per month

    Hi,
    there is two date columns "from" and "to" in the table "contracts" (contract validity, e.g. from 01.03.2012 to 31.12.2014). How to select the count of valid contratc per month ?
    Result:
    month valid contracts
    03.2012 2341
    04.2012 2355
    Thanks in advance,
    Michel

    Hi, Michel,
    Michel77 wrote:
    Hi,
    there is two date columns "from" and "to" in the table "contracts" (contract validity, e.g. from 01.03.2012 to 31.12.2014). How to select the count of valid contratc per month ?So, if the start_date is in March, 2012, and the end_date is in December, 2014, do you want that 1 contract to be counted 34 times, once for each month from March 2012 through December 2014?
    Here's one way:
    WITH     month_range     AS
         SELECT     TRUNC (MIN (start_date, 'MONTH'))     AS start_month
         ,     TRUNC (MAX (end_date,     'MONTH'))     AS end_month
         FROM     contracts
    ,     all_months     AS
         SELECT     ADD_MONTHS ( start_month
                      , LEVEL - 1
                      )          AS this_month
         ,     ADD_MONTHS ( start_month
                      , LEVEL
                      )          AS next_month
         FROM    month_range
         CONNECT BY     LEVEL <= 1 + MONTHS_BETWEEN ( end_month
                                                 , start_month
    SELECT       a.this_month
    ,       COUNT (c.start_date)     AS valid_contracts
    FROM            all_months  a
    LEFT OUTER JOIN contracts   c  ON  c.start_date          <  a.next_month
                                  AND c.end_date          >= a.this_month
    GROUP BY  a.this_month
    ORDER BY  a.this_month
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and also post the results you want from that data.
    Point out where the statment above is getting the wrong results, and explain, using specific examples, how you get the right results from the given data in those places.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the forum FAQ {message:id=9360002}

  • Count days in a month for a date range

    i am trying to find no. of days between 2 Date Ranges for a list of Ids. i used the logic in the below link:
    count days of the month
    My query is giving duplicates since, I have list of Ids.
    Doctor_ID     Patient_ID     ARRIVE_DT_TM     DISCH_DT_TM
    755722     42972229     10/18/2012 7:50     3/14/2013 20:45
    763305     42972232     1/7/2013 20:27     3/15/2013 19:15
    25391509     42972298     2/4/2013 22:45     3/8/2013 22:03
    746779     42972331     1/4/2013 23:00     3/26/2013 21:50
    763305     42972338     3/4/2013 22:19     3/6/2013 19:35
    763305     42972411     11/4/2013 22:32     3/29/2013 17:30
    I am looking for query to give me for Patient_ID = 42972229
    MONTH     COUNT_DAYS
    201210     14
    201211     30
    201212     31
    201301     31
    201302     28
    201303     14
    I am running the following code and it loops through the months and gives duplicates when I remove where Patient_id IN (42972229)
    select
    Doctor_ID
    , Patient_ID
    , AR_DTTM
    , DSC_DTTM
    , TO_CHAR(ADD_MONTHS(TRUNC(date1, 'MONTH'), LEVEL - 1), 'YYYY MM') MONTHS_BET
    , (LEAST(date2, ADD_MONTHS(TRUNC(date1, 'MONTH') - 1, LEVEL)) - GREATEST(date1, ADD_MONTHS(TRUNC(date1, 'MONTH'), LEVEL - 1)))+ 1 AS DAYSCOUNT
    from (select
    Doctor_ID
    , Patient_ID
    , ARRIVE_DT_TM AR_DTTM
    , DISCH_DT_TM DSC_DTTM
    ,TRUNC(ARRIVE_DT_TM,'DDD') AS date1
    ,TRUNC(DISCH_DT_TM,'DDD') AS date2
    from temp where Patient_id IN (42972229)
    CONNECT BY LEVEL <= MONTHS_BETWEEN(TRUNC(date2, 'MONTH'), TRUNC(date1, 'MONTH')) + 1
    Please help!

    Hi,
    ASTRA_007 wrote:
    Results I would like to see are:
    Doctor_ID     Patient_ID     ARRIVE_DT_TM     DISCH_DT_TM     Month     CountofDays
    755722     42972229     10/18/2012 7:50     3/14/2013 20:45     2012 10     14
    755722     42972229     10/18/2012 7:50     3/14/2013 20:45     2012 11     30
    755722     42972229     10/18/2012 7:50     3/14/2013 20:45     2012 12     31
    755722     42972229     10/18/2012 7:50     3/14/2013 20:45     2013 01     31
    755722     42972229     10/18/2012 7:50     3/14/2013 20:45     2013 02     28
    755722     42972229     10/18/2012 7:50     3/14/2013 20:45     2013 03     14
    763305     42972232     1/7/2013 20:27     3/15/2013 19:15     2013 01     25
    763305     42972232     1/7/2013 20:27     3/15/2013 19:15     2013 02     28
    763305     42972232     1/7/2013 20:27     3/15/2013 19:15     2013 03     15
    and so on...So each row represents a patient-month, and you want to display several columns from the temp table on each output row. In that case, include all those columns in both the SELECT and GROUP BY clauses, like this:
    WITH     universe     AS
         SELECT     *
         FROM     temp
    --     WHERE     patient_id     IN (42972229)
    ,     date_range     AS
         SELECT     TRUNC (MIN (arrive_dt_tm))     AS first_date
         ,     TRUNC (MAX (disch_dt_tm))     AS last_date
         FROM     universe
    ,     all_dates     AS
         SELECT     first_date + LEVEL - 1     AS a_date
         FROM     date_range
         CONNECT BY     LEVEL     <= (last_date + 1) - first_date
    SELECT    u.doctor_id
    ,       u.patient_id
    ,       u.arrive_dt_tm
    ,       u.disch_dt_tm
    ,       TO_CHAR ( TRUNC (a.a_date, 'MONTH')
                  , 'YYYY MM'
                )          AS month
    ,       COUNT (*)          AS count_days
    FROM       all_dates  a
    JOIN       universe   u  ON  a.a_date  BETWEEN  TRUNC (u.arrive_dt_tm)
                                         AND      u.disch_dt_tm
    GROUP BY  u.doctor_id
    ,       u.patient_id
    ,       u.arrive_dt_tm
    ,       u.disch_dt_tm
    ,         TRUNC (a.a_date, 'MONTH')
    ORDER BY  u.patient_id
    ,       TRUNC (a.a_date, 'MONTH')
    ;Output from your sample data (with no filtering):
    `DOCTOR_ID PATIENT_ID ARRIVE_DT_TM     DISCH_DT_TM      MONTH   COUNT_DAYS
        755722   42972229 10/18/2012 7:50  3/14/2013 20:45  2012 10         14
        755722   42972229 10/18/2012 7:50  3/14/2013 20:45  2012 11         30
        755722   42972229 10/18/2012 7:50  3/14/2013 20:45  2012 12         31
        755722   42972229 10/18/2012 7:50  3/14/2013 20:45  2013 01         31
        755722   42972229 10/18/2012 7:50  3/14/2013 20:45  2013 02         28
        755722   42972229 10/18/2012 7:50  3/14/2013 20:45  2013 03         14
        763305   42972232 1/7/2013 20:27   3/15/2013 19:15  2013 01         25
        763305   42972232 1/7/2013 20:27   3/15/2013 19:15  2013 02         28
        763305   42972232 1/7/2013 20:27   3/15/2013 19:15  2013 03         15
      25391509   42972298 2/4/2013 22:45   3/8/2013 22:3    2013 02         25
      25391509   42972298 2/4/2013 22:45   3/8/2013 22:3    2013 03          8
        746779   42972331 1/4/2013 23:0    3/26/2013 21:50  2013 01         28
        746779   42972331 1/4/2013 23:0    3/26/2013 21:50  2013 02         28
        746779   42972331 1/4/2013 23:0    3/26/2013 21:50  2013 03         26
        763305   42972338 3/4/2013 22:19   3/6/2013 19:35   2013 03          3
    In the end the objective is to count the no. of days in each month between the arrival and discharge dates by Physician and for his/her patients.Then is the output above really what you want? Say you're interested in physician 763305. That physician had 18-patient days in March, 2013, but the output doesn't make it clear.
    I ran your query, it works great but I have a long list of patients for whom I have to run these counts.the query above includes all patient_ids.
    That's a separate problem, to be solved in the first sub-query, universe. The rest of the query will be unchanged.
    How will you know which patients to include? If you can derive the list from temp itself, just use a WHERE clause in universe. If you need to look at other tables, join them in universe, or use them in sub-queries in universe, or both.
    For exmple, if you decide that the list of patient_ids has no pattern, and that you'll need to store their ids in a separate table (perhaps a global temporary table), then universe might be:
    WITH     universe     AS
         SELECT     t.*     -- or list columns needed
         FROM     temp                        t
         JOIN     patient_ids_to_include  p 
                      ON  p.patient_id = t.patient_id
    ) ...The rest of the query can be the same as above.
    If a same patient is admitted again then Patient_ID will be different no matter when readmitted.Are you saying that patient_id identifies a visit, not a patient, and that the same person is assigned a different patient_id every time that person is admitted?
    For
    INSERT INTO temp (doctor_id, patient_id, arrive_dt_tm, disch_dt_tm)
    VALUES ( 755722
    , 42972229
    , TO_DATE ('03/14/2013 23:00', 'MM/DD/YYYY HH24:MI')
    , TO_DATE ('04/01/2013 12:00', 'MM/DD/YYYY HH24:MI')
    First the Patient ID will be different from the earlier admission. Second the results will show like:
    Doctor_ID     Patient_ID     ARRIVE_DT_TM     DISCH_DT_TM     Month     CountofDays
    755722     42972229     3/14/2013 23:00     4/1/2013 12:00     2012 03     14
    755722     42972229     3/14/2013 23:00     4/1/2013 12:00     2012 04     1Are you saying that temp.patient_id is unique, and so the situation is impossible?
    Edited by: Frank Kulash on May 7, 2013 10:23 AM

  • Chart: amount (count) of records per month (and year). How?

    I need to create a chart eventually. Can't get what formula to use. The data is:
    1 | 15 Jan
    2 | 20 Jan
    25 | 14 Mar
    26 | 16 Mar
    28 | 20 Mar
    The chart should show amount(count) of records per month(and year). So in this example:
    Jan: 2
    Mar: 3
    Hm... totally lost. Any tips?

    To do this it would be best to add a column in which you isolate the month from the rest of the date information. Here's an example:
    You may hide the Month-Isolated column if it impacts your presentation.
    The Month-Isolated formula is: =IF(ISBLANK(B), "", (MONTH(B)))
    The formula for the count in the Summary table is: =COUNTIF(Data Table :: $C, COLUMN())
    Hope this gets you on your way.
    Regards,
    Jerry

  • My 30 day Photoshop trial finished yesterday. I purchased the $9.99 per month Photoshop package and received an email saying "Thank you for your payment etc" But when I go to open PS it still says "the trial has expired.."

    My 30 day Photoshop trial finished yesterday. I purchased the $9.99 per month Photoshop package and received an email saying "Thank you for your payment etc" But when I go to open PS it still says "the trial has expired.." Is it supposed to work automatically or is there a step I'm missing?

    1. Close all the Adobe Applications. Log-out from creative.adobe.com and re-login.
    2. Once you launch the software and when you get the error saying the the trial version has expired, you will have an option saying "License this software".
    3. Select this option and enter your credentials and click next.
    Nancy O.

  • Register Applications photoshop CC   Lightroom 300 baht per month Creative Cloud desktop install and load the program into Lightroom down normally open normally, but the work load photoshop program installed. Open access Like we use it to fill a 30-day tr

    Register Applications photoshop CC   Lightroom 300 baht per month Creative Cloud desktop install and load the program into Lightroom down normally open normally, but the work load photoshop program installed. Open access Like we use it to fill a 30-day trial version, serial no.

    1) WHAT if I juse JUST ONE Adobe program pretty often? 
    They have a single use subscription for $20/mo.  Similar to upgrading extended version every 1.5 years.
    2)  WHAT if I created projects like 2 months ago and I didn't use Photoshop for a full month.  Who assures us that with the CC series the projects are opened with the old CS ones?Or don't use it every day?
    Same problem if you own it.  If upgrade price is $400 every 1.5 year that is same as $16/month.  You can choose not to update and version will be same as when you last used it.
    3) WHAT if I don't use Adobe 24/7?  and 5) Making an day-based subscription??  Same problem if you own it.  If upgrade price is $400 every 1.5 year that is same as $16/month.
    4) Adobe, do you think to be the only one making these softwares?
    Competition is always a factor in market.
    6) After all this mess, you discriminate Europeans, too?
    Taxes charged by Governments and municipalities are not controlled by Adobe.

  • I need to display, a record  count on a column within a table per month

    This is what i currently have...but not what i am looking for...
    select creation_date,
    sum(DECODE(to_char(creation_date, 'MM/DD/YYYY HH24:MI:SS'),'01', 1,0)) JAN,
    sum(DECODE(to_char(creation_date, 'MM/DD/YYYY HH24:MI:SS'),'02', 1,0)) FEB,
    sum(DECODE(to_char(creation_date, 'MM/DD/YYYY HH24:MI:SS'),'03', 1,0)) MAR,
    sum(DECODE(to_char(creation_date, 'MM/DD/YYYY HH24:MI:SS'),'04', 1,0)) APR,
    sum(DECODE(to_char(creation_date, 'MM/DD/YYYY HH24:MI:SS'),'05', 1,0)) MAY,
    sum(DECODE(to_char(creation_date, 'MM/DD/YYYY HH24:MI:SS'),'06', 1,0)) JUN,
    sum(DECODE(to_char(creation_date, 'MM/DD/YYYY HH24:MI:SS'),'07', 1,0)) JUL,
    sum(DECODE(to_char(creation_date, 'MM/DD/YYYY HH24:MI:SS'),'08', 1,0)) AUG,
    sum(DECODE(to_char(creation_date, 'MM/DD/YYYY HH24:MI:SS'),'09', 1,0)) SEP,
    sum(DECODE(to_char(creation_date, 'MM/DD/YYYY HH24:MI:SS'),'10', 1,0)) OCT,
    sum(DECODE(to_char(creation_date, 'MM/DD/YYYY HH24:MI:SS'),'11', 1,0)) NOV,
    sum(DECODE(to_char(creation_date, 'MM/DD/YYYY HH24:MI:SS'),'12', 1,0)) DEC,
    count(*) TOTAL
    from applsys.fnd_user
    where creation_date > to_date('01/01/2010','MM-DD-YYYY')
    GROUP BY creation_date
    order by 1;
    I need the amount of users added to be displayed per month..together with a total...
    output similar to this:
    COYDIV      JAN     FEB     MAR     APR     MAY     JUN     JUL     AUG     SEP     OCT     NOV     DEC      TOTAL
    101     4     0     1     0     0     0     0     0     0     0     0     0     5
    102     0     3     0     0     0     0     0     0     0     0     0     0     3
    103     0     1     1     0     0     0     0     0     0     0     0     0     2
    104     0     1     0     0     0     0     0     0     0     0     0     0     1
    105     0     0     1     0     0     0     0     0     0     0     0     0     1
    107     1     0     0     0     0     0     0     0     0     0     0     0     1
    108     0     1     0     0     0     0     0     0     0     0     0     0     1
    109     2     0     2     0     0     0     0     0     0     0     0     0     4
    117     0     0     2     0     0     0     0     0     0     0     0     0     2
    118     0     0     1     0     0     0     0     0     0     0     0     0     1
    119     0     0     1     0     0     0     0     0     0     0     0     0     1
    122     0     1     0     0     0     0     0     0     0     0     0     0     1
    201     1     0     0     0     0     0     0     0     0     0     0     0     1
    401     4     0     1     0     0     0     0     0     0     0     0     0     5
    403     0     1     0     0     0     0     0     0     0     0     0     0     1
    603     0     0     1     0     0     0     0     0     0     0     0     0     1
    609     0     0     3     0     0     0     0     0     0     0     0     0     3
    612     1     0     0     0     0     0     0     0     0     0     0     0     1
    615     0     2     0     0     0     0     0     0     0     0     0     0     2
    619     0     0     1     0     0     0     0     0     0     0     0     0     1
    2001     0     2     2     0     0     0     0     0     0     0     0     0     4
    2201     0     1     2     0     0     0     0     0     0     0     0     0     3
    2301     0     0     1     0     0     0     0     0     0     0     0     0     1
    2302     0     1     0     0     0     0     0     0     0     0     0     0     1
    2303     0     0     1     0     0     0     0     0     0     0     0     0     1
    5001     0     2     3     0     0     0     0     0     0     0     0     0     5
    TOTAL     13     16     24     0     0     0     0     0     0     0     0     0     53
    any ideas on how i can remedy my script

    Ok here goes
    1. boldVersion 11.1.0.7.0
    2. boldsample data
    "USER_ID","USER_NAME", "LAST_UPDATE_DATE", "LAST_UPDATED_BY", "CREATION_DATE", "CREATED_BY","LAST_UPDATE_LOGIN","SESSION_NUMBER","START_DATE","END_DATE","DESCRIPTION", "LAST_LOGON_DATE","PASSWORD_DATE","PASSWORD_ACCESSES_LEFT","PASSWORD_LIFESPAN_ACCESSES","PASSWORD_LIFESPAN_DAYS","EMPLOYEE_ID","EMAIL_ADDRESS","FAX","CUSTOMER_ID","SUPPLIER_ID","WEB_PASSWORD","USER_GUID","GCN_CODE_COMBINATION_ID","PERSON_PARTY_ID"
    2289, [email protected], 3/24/2010 12:37:23 PM, 2289, 1/18/2010 12:22:49 PM, 1295, 4975366, 24, 1/18/2010, ,Cecilia Buthelezi,4/6/2010 8:46:36 AM,3/24/2010 12:37:23 PM,,,30,8180,[email protected],,,,,,,20702
    2269, [email protected], 3/24/2010 3:40:47 PM, 2269, 1/14/2010 3:42:58 PM, 1295, 4917252, 10, 1/14/2010, ,Heather Summers, 3/24/2010 3:40:48 PM,3/24/2010 3:40:47 PM,,,30,2237,[email protected],,,,,,,7169
    3. boldexpected out put
    JAN     FEB     MAR     APR     MAY     JUN     JUL     AUG     SEP     OCT     NOV     DEC      TOTAL
    4     0     1     0     0     0     0     0     0     0     0     0     5
    0     3     0     0     0     0     0     0     0     0     0     0     3
    TOTAL     13     16     24     0     0     0     0     0     0     0     0     0     53
    etc
    4. boldExplanation of expected output
    a select statement using the creation date, for users added per month and total users added for months in which users were added.
    thanks
    Edited by: user11978142 on Apr 6, 2010 5:46 AM

  • My iPhone 4 crashes very often (3-4 times per day) and sometimes (2-3 times per month) all my apps disappear and I have to restore them with iTunes. I downloaded all the system updatings and I also tried to restore my device, but I still have this issue

    My iPhone 4 crashes very often (3-4 times per day) and sometimes (2-3 times per month) all my apps disappear and I have to restore them with iTunes. I downloaded all the system updatings and I also tried to restore my device, but I still have this issue

    If you haven't already, try restoring your iPhone as a new device, not from a backup, and with only the apps Apple includes. Then see if the problems persist. It's possible that a corrupted file on the iPhone is causing the problems, and that could perhaps be coming back onto the iPhone if you're restoring using a backup. Problems with an app could also be causing problems. If the problems persist after restoring the iPhone as "new", then you almost certainly have a defective iPhone and will need to contact Apple for servicing.
    If the problems go away after restoring the iPhone as "new", then you can start putting your other apps back on and see if the problems reappear; if they do, you probably have a badly-coded app.
    Regards.

  • How to find out the Transactions used per month & the USER who used that

    Hi,
    1)How to find out the Transactions used per month & the USER who used that?
    2)and can i get the above same for minimum 20 month?
    System : SAP- Enterprise Core Component.

    You can use my program...
    *& Report  Z_ABAP_TCODE_MONITOR
    *****&  Program Type          : Report                                 *
    *****&  Title                 : Z_ABAP_TCODE_MONITOR                   *
    *****&  Transaction code      : ZTCODE_USAGE                           *
    *****&  Developer name        : Shailendra Kolakaluri                  *
    *****&  Deveopment start date : 26 th Dec 2011                         *
    *****&  Development Package   : ZDEV                                   *
    *****&  Transport No          : DEVK906086                                       *
    *****&  Program Description   : This program is to display
    *List all tcodes executed during previous day.
    *& Show the number of users executing tcodes
    *& Modification history
    REPORT  Z_ABAP_TCODE_MONITOR.
    *& List all tcodes executed during previous day.
    *& Show the number of users executing tcodes
    TYPE-POOLS : slis.
    DATA: ind TYPE i,
          fcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,
          layout TYPE slis_layout_alv,
          variant TYPE disvariant,
          events  TYPE slis_t_event WITH HEADER LINE,
          heading TYPE slis_t_listheader WITH HEADER LINE.
    *REPORT  z_report_usage.
    TYPES: BEGIN OF zusertcode,
      date   TYPE swncdatum,
      user   TYPE swncuname,
      mandt     TYPE swncmandt,
      tcode     TYPE swnctcode,
      report TYPE swncreportname,
      count     TYPE swncshcnt,
    END OF zusertcode.
    *data   : date type n.
    DATA: t_usertcode  TYPE swnc_t_aggusertcode,
          wa_usertcode TYPE swncaggusertcode,
          wa           TYPE zusertcode,
          t_ut         TYPE STANDARD TABLE OF zusertcode,
          wa_result    TYPE zusertcode,
          t_result     TYPE STANDARD TABLE OF zusertcode.
    PARAMETER: month TYPE dats DEFAULT sy-datum.
    *PARAMETER: date TYPE dats.
    *select-options : username for wa_usertcode-account.
    START-OF-SELECTION.
    PERFORM get_data.
    PERFORM get_fieldcatalog.
      PERFORM set_layout.
    PERFORM get_event.
    PERFORM get_comment.
      PERFORM display_data.
    FORM get_data .
    *date = sy-datum - 2 .
    After start-of-selection add this line (parameter Month required 01 as day).
      concatenate month+0(6) '01' into month.
      CALL FUNCTION 'SWNC_COLLECTOR_GET_AGGREGATES'
        EXPORTING
          component     = 'TOTAL'
          ASSIGNDSYS    = 'DEV'
          periodtype    = 'M'
          periodstrt    = month
        TABLES
          usertcode     = t_usertcode
        EXCEPTIONS
          no_data_found = 1
          OTHERS        = 2.
      wa-date  = month.
    *wa-date  = date.
      wa-mandt = sy-mandt.
    wa_usertcode-account = username.
      LOOP AT t_usertcode INTO wa_usertcode.
        wa-user = wa_usertcode-account.
        IF wa_usertcode-entry_id+72 = 'T'.
          wa-tcode  = wa_usertcode-entry_id.
          wa-report = space.
        ELSE.
          wa-tcode  = space.
          wa-report = wa_usertcode-entry_id.
        ENDIF.
        COLLECT wa INTO t_ut.
      ENDLOOP.
      SORT t_ut BY report ASCENDING.
      CLEAR: wa, wa_result.
    endform.
    FORM get_fieldcatalog .
    fcat-tabname     = 't_ut'.
    fcat-fieldname   = 'DATE'.
    fcat-seltext_l   = 'Date'.
    fcat-key         = 'X'.
    APPEND fcat.
      CLEAR fcat.
      fcat-tabname     = 't_ut'.
      fcat-fieldname   = 'MANDT'.
      fcat-seltext_l   = 'Client'.
      fcat-key         = 'X'.
      APPEND fcat.
      CLEAR fcat.
      fcat-tabname     = 't_ut'.
      fcat-fieldname   = 'USER'.
      fcat-seltext_l   = 'User Name'.
      fcat-key         = 'X'.
      APPEND fcat.
      CLEAR fcat.
      fcat-tabname     = 't_ut'.
      fcat-fieldname   = 'TCODE'.
      fcat-seltext_l   = 'Transaction Code'.
      fcat-key         = 'X'.
      APPEND fcat.
    ENDFORM.
    *&      Form  SET_LAYOUT
          text
    -->  p1        text
    <--  p2        text
    FORM set_layout .
      layout-colwidth_optimize = 'X'.
    ENDFORM.                    " SET_LAYOUT
    *&      Form  GET_EVENT
          text
    -->  p1        text
    <--  p2        text
    *FORM get_event .
    events-name = slis_ev_top_of_page.
    events-form = 'TOP_OF_PAGE'.
    APPEND events.
    *ENDFORM.                    " GET_EVENT
    **&      Form  GET_COMMENT
          text
    -->  p1        text
    <--  p2        text
    *FORM get_comment .
    DATA: text(30).
    text = 'Billing Report'.
    heading-typ = 'H'.
    heading-info = text.
    APPEND heading.
    *ENDFORM.                    " GET_COMMENT
    **&      Form  top_of_page
          text
    -->  p1        text
    <--  p2        text
    *FORM top_of_page .
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
       EXPORTING
         it_list_commentary       = heading[]
      I_LOGO                   =
      I_END_OF_LIST_GRID       =
    *ENDFORM.                    " top_of_page
    *&      Form  DISPLAY_DATA
          text
    -->  p1        text
    <--  p2        text
    FORM display_data .
      sort t_ut[].
    DELETE ADJACENT DUPLICATES FROM t_ut[] COMPARING ALL FIELDS.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program = sy-cprog
          is_layout          = layout
          it_fieldcat        = fcat[]
          i_save             = 'A'
          is_variant         = variant
          it_events          = events[]
        TABLES
          t_outtab           = t_ut
        EXCEPTIONS
          program_error      = 1
          OTHERS             = 2.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDFORM.                    " DISPLAY_DATA

  • A query with workingdays per month per persons per period

    Can anyone help me on the way in building a difficult SQL query?
    I work with Oracle SQL. It is intended to calculate over a certain period, to find the working days for each month for each person.
    I have a working query for calculate the number of days for 1 months minus holidays
    Select count (*) NUM_WORK_DAYS
    From (
    Select to_date ('01-01-2010 ',' dd-mm-yyyy ') + ROWNUM-1 as day
    From all_objects
    Where ROWNUM <to_number (to_char (last_day ('01-01-2010 '), DD')) + 1)
    Where to_number (to_char (day, 'd')) between 1 and 5
    And not exists (select NULL
    From HOLIDAY
    Where Holiday.hol=day)
    There is a datetable with the following structure where I can get the periods:
    DATES
    YEAR | MONTH | WEEK | SD
    2010 | 201002 | 201006 | 09/02/2010
    All required months are present
    It is intended that the user give a beginning and a end time specify.
    I have a table of workingdays per person named
    CALENDAR
    CAL | MON | TUE | WED | THU | FRI | SAT | SUN
    Person | Y | Y | N | Y | Y | N | N
    And a table of holidays
    HOLIDAY
    CAL | HOL
    Person | 01/01/2010
    How can I combine the query for working days and build a query that returns for multiple people over multiple months the number of workingdays per month? I will ask the user to give a beginning period and a end period
    I am aware that I ask a lot of your time, but I can not imagine the solution myself. Many thanks in advance
    Gr,
    Els

    You can do something like this:
    SQL> select * from calendar;
        PERSON M T W T F S S
             1 Y Y N Y Y N N
             2 Y Y Y Y Y N N
    SQL> select * from holiday;
        PERSON HOL
             1 12-FEB-10
             2 09-FEB-10
    SQL> define start_day=2010-02-01
    SQL> define end_day=2010-02-20
    SQL> with period as (
      2  select DATE '&start_day' start_date, DATE '&end_day' end_date
      3    from dual),
      4  days as (
      5  select start_date+level-1 day
      6    from dual,period
      7  connect by level <= end_date-start_date+1),
      8  mycal as (
      9  select person, 'monday' day, mon works from calendar union all
    10  select person, 'tuesday' day, tue from calendar union all
    11  select person, 'wednesday' day, wed from calendar union all
    12  select person, 'thursday' day, thu from calendar union all
    13  select person, 'friday' day, fri from calendar union all
    14  select person, 'saturday' day, sat from calendar union all
    15  select person, 'sunday' day, sun from calendar
    16  )
    17  select person, count(0)
    18    from mycal c, days d
    19   where c.day = trim(to_char(d.day,'day'))
    20     and c.works='Y'
    21     and not exists (select 1 from holiday h where h.person=c.person and h.hol=d.day)
    22  group by person;
    old   2: select DATE '&start_day' start_date, DATE '&end_day' end_date
    new   2: select DATE '2010-02-01' start_date, DATE '2010-02-20' end_date
        PERSON   COUNT(0)
             1         11
             2         14The PERIOD view is there only to accept start and end date.
    The DAYS view contains all the days of the period
    The MYCAL view unpivotes the calendar days returning 7 rows for each person, a row per weekday
    Max
    http://oracleitalia.wordpress.com

  • Get date by group by per month basis...

    Hello all,
    I am trying to write a query where i want the count per month...so for example...the below query
    select to_char(date, 'MM/DD/YYYY')
    from test
    where rownum < 10;
    TO_CHAR(date
    02/10/2009
    02/10/2009
    02/10/2009
    02/10/2009
    02/10/2009
    05/31/2009
    02/10/2009
    so i want a count on the date, but want it per month basis....
    select count(*), to_char(date, 'MM/DD/YYYY')
    from test
    where rownum < 10
    group by to_char(date, 'MM/DD/YYYY');
    so basically end results should be like below
    count(*) date
    10 Month1
    12 Month2
    13 Month3

    Hi,
    You're GROUPing BY something that changes from day to day.
    You need to GROUP BY something that only changes from month to month, like this:
    SELECT    COUNT (*)
    ,        TO_CHAR (dt, 'MM/YYYY')     -- DATE is not a good column name
    FROM        test
    WHERE       ROWNUM     < 10
    GROUP BY  TO_CHAR (dt, 'MM/YYYY')
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and also post the results you want from that data.
    Explain, using specific examples where the query above is not doing what you want, how you get the correct results from the data you posted.

  • Am I notified when my 50 uploads per month is reached?   What is revels definition of a month?

    Am I notified when I reach my 50 uploads per month? How does revel count its month?(1st to last day etc.

    Hello
    Yes you are notified of how many pictures that you would have remaining for the month. The upload count is reset on the first day of the month.
    Here is screen shot of what you would see using Adoberevel.com and if you were using the Ipad
    If you are interested in upgrading to Revel Premium, then please our FAQ post http://forums.adobe.com/thread/1178780?tstart=0 as you will see screens shots of this.
    Thanks
    Scott

Maybe you are looking for

  • How can I display the photos and videos from the Nano to Altec's iMV712

    I am trying to display photos and videos from a 3G Nano to larger display on Altec Lansings iMV712 While I know I can view it from the cradle, I was wondering if a TV Out would work? Has anyone managed to get this to work?

  • Logical export

    In Lookout when I go to Historical data viewer and select a view to export, that is a logical value that is a switch, when I look at the text of the export all the values are just opposite of the real value of the switch. That is at the time it said

  • Adobe AIR project - Questions

    Hello I m here to solve any questions related to AIR in my mind. I would start an offline project that consist of displaying and editing things in a db.I would like to develop this project over AIR and Action Script 3.I know that AS3 can handle Mysql

  • Mark up text with edits

    This question was posted in response to the following article: http://help.adobe.com/en_US/acrobat/pro/using/WS58a04a822e3e50102bd615109794195ff-7e73.w.h tml

  • Release Strategy in SCN

    HI MM Consultants Is it posible to maintain release strategy in SCN pls help its urgent