Calculate Present, absent days

in my asp.net+vb+sql web is was trying to make a calculation of absent days. There are two dropdown lists to select Month , Year
if i select Jan and 2015 in drop downlists. i want out put as 
MID, Name, Room_No, Preasnt_days, absent_days
i made the tables and inserted data into it. i was not able to query in correctly.
I had made  the sql fiddle here http://sqlfiddle.com/#!6/e5a20
I am a System Administrator at Vadodara

sir, if you watch my fiddle there is a problem if person is absent from 1 Jan 15 to 2 Feb 2015 as per the query it shows 32 dats absent as shown below.
 http://sqlfiddle.com/#!6/e5a20/1
I am a System Administrator at Vadodara
Hi Baiju,
In your sample data, there are only Out_dt and In_dt, and the two date can be in different month. It's hard to give the Present and Absent day in a particular month. As Vaibhav said, you can Datediff function to return the days between Out_dt and In_dt.
However this result can be incorrect when the two date belong different month. What you can do is alter the table structure. Record users present or absent every day, then you can return the present and absent day by using COUNT function for a particular
month.
http://stackoverflow.com/questions/4322406/to-count-the-no-of-days-present-and-absent
Regards,
Charlie Liao
TechNet Community Support

Similar Messages

  • How to calculate number of days in hijri

    Dear all,
    I need to develop a custom report in which i required to calculate number of days in hijri month and also the first and last day of the hijri month. we normally use Last_date(sysdate) function to get the last date of the english calender. but how can we find same for month.
    Looking after for your support.
    Regards,
    Saquib

    Convert to hirjih date using:
    select
    to_char(sysdate,'YYYY/MM/DD','NLS_CALENDAR=''English Hijrah''') hijrih_date
    from dual;
    You can replace sysdate with the date of your choice.
    Also I wrote this for my last project:
    /* get hirjih date */
    FUNCTION get_hijrah_date(
    p_date in date,
    p_date_format in varchar2
    ) return varchar2
    is
    v_hijrah_date varchar2(500);
    begin
    select
    to_char(p_date,p_date_format,'NLS_CALENDAR=''English Hijrah''')
    into v_hijrah_date
    from dual;
    return v_hijrah_date;
    end get_hijrah_date;
    So you can have get_hijrah_date(sysdate,'DD-MON-YYYY') from dual;
    (or any other date formate of your choice)
    Edited by: igwe on Jan 30, 2013 8:07 AM

  • How to calculate no of day in a month

    Hi All,
    I am have one cube in that i am getting only fiscalyear/period and variant.
    now my question is how calculate no of day in my fiscalyear/period (ex : 007.2010) this month of oct .is is possible in update rules.
    or it can be possible in report level
    for this i required ABAP logic any one help on this.
    Reagrds
    Anil

    In update rule / transformation write routine, in routine use function module /OSP/GET_DAYS_IN_MONTH. pass  period/month as input to routine/FM & output of this function module get into one variable & pass that variable to result.
    CALL FUNCTION '/OSP/GET_DAYS_IN_MONTH'
      EXPORTING
        iv_date       = SOURCE_FIELDS-fiscper
    IMPORTING
       EV_DAYS       = days
    Result =  days
    Days is a variable declare locally in routine
    Edited by: Swapnil Dharia on Jan 14, 2010 2:36 PM

  • How to calculate no of days in an year

    Hi,
    can some one provide a simple way to calculate no of days in a year if we know processing date.
    thanks
    CDPrasad

    select
       trunc(input_date, 'YYYY')  as the_year,
       add_months(trunc(input_date, 'YYYY'), 12)
       trunc(input_date, 'YYYY')  as days_in_year  
    from
       select
          add_months(sysdate, -12 * level) as input_date
       from dual
       connect by level <= 20
    12  );
    THE_YEAR          DAYS_IN_YEAR
    01-JAN-2009 12 00:00           365
    01-JAN-2008 12 00:00           366
    01-JAN-2007 12 00:00           365
    01-JAN-2006 12 00:00           365
    01-JAN-2005 12 00:00           365
    01-JAN-2004 12 00:00           366
    01-JAN-2003 12 00:00           365
    01-JAN-2002 12 00:00           365
    01-JAN-2001 12 00:00           365
    01-JAN-2000 12 00:00           366
    01-JAN-1999 12 00:00           365
    01-JAN-1998 12 00:00           365
    01-JAN-1997 12 00:00           365
    01-JAN-1996 12 00:00           366
    01-JAN-1995 12 00:00           365
    01-JAN-1994 12 00:00           365
    01-JAN-1993 12 00:00           365
    01-JAN-1992 12 00:00           366
    01-JAN-1991 12 00:00           365
    01-JAN-1990 12 00:00           365
    20 rows selected.
    TUBBY_TUBBZ?The above shows the number of days in a year for the past 20 years.
    So assuming you had a variable .. called "input_date"
       trunc(input_date, 'YYYY')  as the_year,
       add_months(trunc(input_date, 'YYYY'), 12)
       trunc(input_date, 'YYYY')  as days_in_year   Would do it.

  • Function module to calculate no of days between two date ranges

    hi experts,
    can some one please suggest a function module that can calculate no of days between specified date range.
    for example : if i enter date range between 26.02.2011 to 20.05.2011, then it should calculate no of days between these dates.
    Moderator message : Basic date questions not allowed. Read forum rules before posting. Thread locked.
    Edited by: Vinod Kumar on May 25, 2011 10:57 AM

    Hi,
    Please search SDN.. there are lots of posts for teh same.
    [http://wiki.sdn.sap.com/wiki/display/ABAP/FunctionModulerelatedonDate+calculations]

  • Calculate the working days having the start and end dates only

    Hi,
    Can BIP be able to calculate the working days having the start and end dates only? It is like the NETWORKDAYS function in Excel. (i.e. excluding weekends and holidays).
    Thanks.

    Not out of the box.
    But You could extend your BIP functions
    Look at here:
    http://blogs.oracle.com/xmlpublisher/2009/05/bip_by_extension.html
    Based on that what you need is similar to the following Java code:
    http://objectlabkit.sourceforge.net/
    regards
    Jorge A.

  • Formula to calculate number of days between today's date & given date BEx

    Hello,
    I have a date available as an attribute of dimension characteristic. How do I get current date (sy-datum) to calculate the # of days (or difference) between query execution date and given date.
    Is there a system field to get current or today's date .
    I am thinking to have this as calculated KF in BEx.
    Any suggestions or tips
    Thanks

    Hi,
    Create a variable on the attribute(date attribute) of characterstic. Use this variable to create a formula variable , in which you fin out the difference between current date and varaible.
    There  is a good document on using the attributes in the calculation in service.sap.com/bi
    In infoindex--> calculation with attributes.
    With rgds,
    Anil Kumar Sharma .P

  • To calculate the last day of a week

    I have this problem.
    I must calculate the last day (saturday) of a week, if I have somewhere day of a week.
    For example
    if today is Thursday 08/03 how can calculate Saturday 10/03?
    Thank's a lot!!!

    The day number given previously is territory dependant. So, in France, the last day of week (day 7) is sunday instead of saturday...
    You can try to work with next_day function, which is more independant :
    SQL> select to_char(sysdate,'d') from dual;
    T
    4
    SQL> select next_day(sysdate-1,'saturday') from dual;
    NEXT_DAY
    10/03/07
    SQL> alter session set nls_territory='america';
    Session altered.
    SQL> select to_char(sysdate,'d') from dual;
    T
    5
    SQL>
    SQL> select next_day(sysdate-1,'saturday') from dual;
    NEXT_DAY(
    10-MAR-07
    SQL> Nicolas.

  • How to calculate Date and Days

    Hi BW Experts,
    I have requirement, I have field original GI Date and  it is calculating based on 'Original promise date'-'Transport time'. Formula is 'Original GI Date' = 'Original promise date'-'Transport time'.
    We are getting data for original promise date as Date format and  Transport time as Days (ex: 1 or 2 days).
    Here, how can I convert into Date or how can I calculate Date and Days. I am working on BW3.5 .
    Please help me how can I overcome this requirement.
    Points will be assign.
    regards
    Yedu.

    Hi Ventatesh
    It's not a problem
    You can subtract days from date to get the resultant date
    Original Promise time  =  GI Date  - Transit time ( in days)
    Add Original Promise Time in your data target and fill that up with the above rule.
    If the above is not working you can use this function module
    DATE_IN_FUTURE
    Here you need to pass Date and Days to get future date. Only trick you need to apply that if the transit days is 5 days, you pass -5 to this function module.
    But this function module is not available in BW system. Just copy the code from ECC system and create a Z FM for BW system
    Regards
    Anindya
    Edited by: Anindya Bose on Feb 9, 2012 4:36 AM

  • Consider the Off day as Absent day

    Hi Experts,
    i am facing one problem while marking absence of employees in PA30 (IT2001)
    Absence is being marked from 06.01.2012 to 08.01.2012 system gives below error message
    "Last day 08.01.2012 of attendance/absence is a day off (att./absence type LWP)"
    If an employee goes on Leave without pay:
    My problem is how to Consider this Off day as Absent day for Employee so that his salary is deducted for this Off day also ?
    thanks

    Hi,
    Whatever you raised the issues with possible Counting rule..
    I was mentioned every thing in my earlier reply.. You need to select all week days, select all DWS class (0-9), select Holiday class (Depends upon client business, otherwise select not a public holiday),  select All day types..Select all counting class, select conditions for planned hours (two options i mean both), select conditions for absence/attendance (two options, i mean both of that), counting in days in hours and days as"100".
    the save record, Enough it will work..
    Note: you need to do all your ESG for time Quotas, PSG for Time Quotas which of the using all counting rules i mean your create 3 groups and 3 counting rules (With same number only) for LWP then need to changes all the rules.
    Hope this clear..

  • Calculate total empoyee days (as of present) that have elapsed for each month in a FY

    Hello, everyone,
    I'm running CF server connecting to an Oracle (11g)  db.
    I have a table that keeps track of projects (past, present, future) and need a way to sum the days for each project, for each month, that have happened.
    For example.
    ID   -
    Name         
    -   Start
    -   Stop 
    - Employees
    001
    Project A     
    01-Oct-14
    31-Dec-14      
    8
    002
    Project B     
    06-Feb-15
    21-Feb-15      
    9
    003
    Project C     
    30-Oct-14
    29-Nov-14      
    3
    004
    Project D     
    26-Dec-14
    16-Apr-15     
    21
    I'm trying to create an overview where the display will have the months of a Fiscal Year go across the page, indicating the number of employee days for each project that have elapsed. (NOT counting the current day).  New requirement: To make matters even more complex, there is a related table for the employees showing what dates they actually started and stopped (not every employee starts on day 1 and ends on the last day.. some start a day or two after the project start, etc.)
    I'm not wrapping my head around this, for some reason. Mental block. Any ideas?
    Someone in another forum suggested a PIVOT.  That's above my paygrade (I have never used PIVOT, don't understand how it works, etc.)
    V/r,
    ^_^

    This may be a good start. Display by Month Year the Average and Sum Dates between Start and Stop by Project.
    SELECT      CAST    (
            (CAST(MONTH(Start) AS varchar(2)) + '/01/' + CAST(YEAR(Start) AS varchar(4)))
            AS DateTime
        AS DatePeriod,
        AVG(DateDiff(day, Start, Stop)) AS AverageDaysToClose,
        SUM(DateDiff(day, Start, Stop)) AS SumTotalDaysToClose,
        Name
    FROM     Projects
    GROUP BY CAST    (
            (CAST(MONTH(Start) AS varchar(2)) + '/01/' + CAST(YEAR(Start) AS varchar(4)))
            AS DateTime
        Name
    ORDER BY DatePeriod, Name

  • Formula to calculate the last day of the subsequent month

    Hi - I am trying to create a formula in CR9 that will take a date field and translate it to the last day of the subsequent month.  For example, I have a date of today, 2/3/2009.  I need it to print on the report 3/31/2009.  I have made some progress to get me the 1st day of the subsequent month, but I need it to be the last day of the subsequent month.
    The formula I am have currently is:
    DateSerial(Year({Name.JOIN_DATE}), Month({Name.JOIN_DATE}) + 1, 0)+1
    this will give me 3/1/2009, but I need 3/31/2009.
    Any help appreciated. 
    Thanks!

    Hi Joe,
    You can use the following logic which also takes into account the extra day in a leap year.  You will need 5 formulas for this:
    First create a formula that calculates current month, call it @Current Month MM
    Month(Name.JOIN_DATE)+1
    Next create another formula called @Current Month Start Date which will give you the beginning of the month.
    totext(Date (year(currentdate),tonumber({@Current Month MM}) ,1 ))
    Next create another formula called @Current Year yyyy
    Year(Name.JOIN_DATE)
    Next, create a formula called @DaysofMonth with the following logic:
    if tonumber({@Current Year yyyy}) mod 4 = 0 then
    choose(month(date({@Current Month Start Date})),31,29,31,30,31,30,31,31,30,31,30,31) else
    choose(month(date({@Current Month Start Date})),31,28,31,30,31,30,31,31,30,31,30,31)
    Lastly create a formula called @Ending Date of Month
    totext(Date (year(currentdate),tonumber({@Current Month MM}) ,{@DaysOfMonth} ))
    I hope this information proves useful.
    Regards,
    Zack H.
    Edited by: Zack H on Feb 3, 2009 5:34 PM
    Edited by: Zack H on Feb 3, 2009 5:38 PM

  • How to calculate number of days excluding weekends

    I have the following <u>key figures</u> in my InfoCube:
    Date Released to Vendors key figure - ZRELDT
    Date Awarded to a Vendor key figure - ZAWRDT
    In my BEx query, I need to calculate the difference between these two key figures but the weekends should be excluded.  For example, if the value of ZRELDT is 08/10/2007 (which is a Friday) and the value of ZAWRDT is 08/13/2007, the result should just be 1 day and not 3 days since the other days pertain to a Saturday and a Sunday.
    How do I address this in the formula when creating the Query?
    thanks.

    Hi,
    Use func module HOLIDAY_GET need to pass the Holiday Cal the company use
    and also 
    FM: DATE_CONVERT_TO_FACTORYDATE.
    One way to use this:
    Assuming:
    - You have the start & end dates in variables.
    - Keep a few counters
    Logic:
    - Pass start date to DATE_CONVERT_TO_FACTORY_DATE with the parameter +
    - If this date is not a factory date, the next date which is a factory day is returned. (I.e. passed Sunday as param, got a Monday date returned). If the day passed to the function is the same as the date returned, this is a factory day (working day)
    - If the date passed to the function is not the same as the returned day then this day was not a factory day, meaning not a work date. Add 1 to a counter
    - Pass the first day + 1 (use another counter for + N)
    - Stop loop when passed parameter is equal to stop date.
    You can replicate the factory calendar from R/3, CRM etc in your source system in RSA1 (transfer globals). In your function call, you specify which factory calendar to use
    hope this help

  • Calculate Difference in Days Between two Dates

    Hi,
    I'm trying to figure out how to calculate the difference in days between two dates using JavaScript in LiveCycle. (JavaScript knowledge = minimal)
    Where "Start_Date" and "Current_Date" are the names of the two dates in the Hierarchy palette. (both Date/Time Field)
    *Current date is using the Object > Value > Runtime Property > Current Date/Time
    I need a Text or Numeric field displaying the difference in days. (Difference_in_Days)
    I've noticed the following code being pretty standard amongst other responses:
    var 
    Start_Date = new Date(Start_Date);
    var 
    Current_Date = new Date(Current_Date);
    var 
    nAgeMilliseconds = Current_Date.getTime() - Start_Date.getTime();
    var 
    nMilliSecondsPerYear = 365 * 24 * 60 * 60 * 1000;
    I know there's code missing, and the above code might not be correct.
    Please advise.

    Where "DateField01" = user entered date field
    Where "DateFiled02" = Current Date/Time (Runtime Property)
    where "Subform" = the subform containing DateField01
    My script now resembles:
    var oneDay = 24*60*60*1000;
    var firstDate = new Date(Subform.DateField01.rawValue);
    var secondDate = new Date(DateField02.rawValue);  
    (firstDate.getTime() - secondDate.getTime()) / oneDay;
    I tried adding:
    app.alert(String(diffDays));
    Although I assume the reason I didn't get an error is because DateField01 is empty when the form is opened.
    If I swap in actual dates instead of fields it works perfectly.
    When I use the fields I have no information populating after I enter a date in "DateField01"

  • How to calculate number of days from a date field

    Dear BW Experts.
    I have a field 'Create Date' in the BEx query. Now we need to create a variable which should give the number of days from the date of running the query (sy-datum) to the Create Date.
    This will help the users to get records which are say, 30 days old (Sy-datum - create date = 30) or 10 days old etc.
    Could you suggest as to how to create this variable.
    Thanks,
    Sai

    Hi,
    Step 1: Create variable on "Create Date" with User entry processing type
    Step 2: Create a restricted KF for Sales & restrict it on "Create Date" to get "Sales on day"
    Step 3: Manipulate  the values of "Create Date" on which you could restrict  "Sales" again and again to get other values
    Step 4: Create one variable (ZPUTMNTH) for u201CMonth to Dateu201D with processing by u201CCustomer Exitu201D. This variable was created  on u201CDateu201D characteristics.
    Step 5 : Goto C-mod t-code and use EXIT_SAPLRRS0_001
    to calculate "month to date" user input is "Calday" Key Date
    WHEN 'ZPUTMNTH'.
    IF I_STEP = 2. "after the popup
    LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE
    WHERE VNAM = 'ZPDATE'.
    CLEAR L_S_RANGE.
    L_S_RANGE-LOW = LOC_VAR_RANGE-LOW(6). "low value, e.g.YYYYMM (200606) part of key date (20060625)
    L_S_RANGE-LOW+6(2) = '01'. u201C low value e..g. YYYYMM01 (20060601)
    L_S_RANGE-HIGH = LOC_VAR_RANGE-LOW. "high value = input
    L_S_RANGE-SIGN = 'I'.
    L_S_RANGE-OPT = 'BT'.
    APPEND L_S_RANGE TO E_T_RANGE.
    EXIT.
    ENDLOOP.
    ENDIF.
    Assign if helps.....
    Regards,
    Suman

Maybe you are looking for

  • Type of Object Permissions

    Hi, I need find table which have all type of permissions to all type of object not specific for user only general information For example USER_TABLE Select USER_TABLE ALTER USER_TABLE UPDATE USER_TABLE View DEFINITION VIEW Update VIEW Select VIEW Alt

  • Checking HANA Table sizes in SAP PO

    Hello All, We have SAP PO 7.4 deployed on SAP HANA SP 09, and the SAP PO is growing fast, and it grew by 200 GB over the last 2 days. The current size of the data volume is showing almost 500 GB just for the PO system. This is HANA tenant database in

  • Multiple Function Acknowledgments (997) to email

    Hi, I have the following problem. We send invoices to an external system and it sends back funtional acknowledgment (ANSI 997). We convert this file with the Seeburger Adapter to an XI-XML and then send it through email to different recepients. Every

  • PROJECT MRP RUN

    Hi all, During mrp run with md03; Planned orders are created according to respective wbs elements. e.g one planned order will be for wbs 1; second for wbs 2 and so on. is it possible to club the requirement of all schemes? Regards Ramesh Arora

  • Db swing components

    Installed jDeveloper, connected to 9i, looks good. But, noticed the component pallette does not include any db component that can be dropped on a standard swing app. Now I remember trying forte and netbeans freebees and recall they lacked db componen