Calculated columns to get difference between two dates with half day

Hi,
So there is the problem I'm using a calculated column to track the number of day when an employee make a vacation request. I'm already taking weekends of the case but now I would need to be able to ask for only a half day off.
How could I perform that without taking out my first requirement?
Just in case there is my current formula:
=IF(AND((WEEKDAY([EndDate],2))<(WEEKDAY([StartDate],2)),((WEEKDAY([StartDate],2))-(WEEKDAY([EndDate],2)))>1),(((DATEDIF([StartDate],[EndDate],"D")+1))-(FLOOR((DATEDIF([StartDate],[EndDate],"D")+1)/7,1)*2)-2),
Thanks for your answers :)  

Hi amber,
you can simple calculate.
try this:
DATA: date1 like sy-datum,
      date2 like sy-datum.
data  I type i.
date1 = '20070301'.
date2 = '20070228'.
i = date1 - date2.
write: / date1, date2, i.
date1 = sy-datum.
date2 = sy-datum - 30.
i = date1 - date2.
write: / date1, date2, i.
Regards, Dieter

Similar Messages

  • How to Calculate AGE by getting difference between two Date Fields

    HI Gems
    I need to calculate AGE from getting difference from two date fields. But when i am trying to wrte fromula as Current date - date1(some date field) then it is showing error.
    How can i get values.
    Thanks
    Manu

    You already asked this question:
    How to calculate AGE from two different date fields

  • Java code to get the difference between two dates in days

    Hi ppl,
    I need to write a user defined function to get the difference between two date nodes, in days.Please help me out
    regards,
    Prashanth

    Hi,
    have a look at those two:
    (How do I calculate the difference between two dates?)
    http://joda-time.sourceforge.net/faq.html
    Calculating the Difference Between Two Datetime Stamps
    http://www.xmission.com/~goodhill/dates/deltaDates.html
    Get difference in days
    http://javaalmanac.com/egs/java.util/CompDates.html
    Regards,
    michal

  • Difference between Two Date Should come into Text Item

    Dear All,
    i want to get difference between two date into text Item :P36_C in On Change java script.
    i have two Date Item :P36_A and :P36_B .i have extract these date value from table then difference comes into Text Field :P36_C.
    Now i want if i change Date into Item :P36_A or Item :P36_B then Defference between two date Should Come into Item :P36_C .
    So i have use Java Script Code to do this
    <script>
      function diffdat(){
        function getVal(item){
       if($x(item).value != "")
         return parseFloat($x(item).value);
       else
         return 0;
        $x('P36_C').value =
    getval((TO_DATE('P36_B', 'DD-MON-YYYY'))-
    getval(TO_DATE('P36_A', 'DD-MON-YYYY')))+1;
    </script>
    i have put this into Item HTML Form Element Attributes 
    onChange="javascript:diffdat();"it's not woring .
    How to work that Code with dates.
    Thanks

    You can always create your own difference function based on your own criteria. You can modify this to suit your needs.
    CREATE OR REPLACE FUNCTION CALC_OFFICE_DAYS(date1 DATE, date2 DATE)
    RETURN NUMBER
    IS
    v_begin_date DATE := date1;
    v_end_date DATE := date2;
    v_office_start_time VARCHAR2(10) := '09:30 AM';
    v_office_end_time VARCHAR2(10) := '06:30 PM';
    v_comp_begin_time DATE;
    v_comp_end_time DATE;
    v_days PLS_INTEGER := 0;
    v_hrs NUMBER := 0;
    v_ttltm NUMBER;
    BEGIN
    select trunc(v_end_date) - trunc(v_begin_date)
    into v_days
    from dual;
    select to_date(to_char(sysdate,'DD-MM-YYYY')||' '||to_char(v_begin_date,'HH24:MI'),'DD-MM-YYYY HH24:MI')
    into v_comp_begin_time
    from dual;
    select to_date(to_char(sysdate,'DD-MM-YYYY')||' '||to_char(v_end_date,'HH24:MI'),'DD-MM-YYYY HH24:MI')
    into v_comp_end_time
    from dual;
    select (v_comp_end_time - v_comp_begin_time)/24 into v_hrs from dual;
    IF v_hrs > 4 then
    v_ttltm := v_days + .5;
    ELSE
    v_ttltm := v_days;
    END IF;
    return v_ttltm;
    END;
    As has been noted, this question is best posted on the PL/SQL forum.

  • [Urgent] Need help calculating difference between two dates

    I'm trying to write a code to display the current day and time, then accept two dates from the user and display the difference between the two dates. To display the current date and time, I've used the SimpleDateFormatter library but I'm having difficulty calculating the difference between two dates. Could someone please help me with this?
    Below is my code so far
    import java.util.Date;
    import java.util.Scanner;
    import java.text.SimpleDateFormat;
    public class DateFormatter {
         public void displayNow()
              Date todaysDate = new Date();
              SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MMM-dd HH:mm:ss");
              String formattedDate = formatter.format(todaysDate);
              System.out.println("Today's date and time is: "+formattedDate);
         public void calculateDifference(Date startDate, Date endDate)
              /* This is whre i need help! */
         public static void main(String[] args)
              DateFormatter df = new DateFormatter();
              Scanner sc = new Scanner(System.in);
              df.displayNow();
              System.out.println("Please enter a date: ");
              String date1 = sc.next();
              System.out.println("Please enter another date: ");
              String date2 = sc.next();
    }The methods displayNow() and calculateDifference(Date startDate, Date endDate) are essential and cannot be skipped out.

    tarahmarie101 wrote:
    Dude. I've tried doing assignments under pressure, and it doesn't work. Here's a piece of free advice. Start earlier next time, don't put "urgent" in the title of your post b/c it just pisses people off around here--and is a sure sign of an overdue homework assignment which no one around here likes helping with, and try to ask intelligent questions--don't just say "Help me!"
    Of course, it takes some time to learn what the intelligent questions are. You have my sympathy. Try asking questions about how to do a particular task, instead of asking people to tell you what to do. It starts to get easier after a while.
    actually dude i started on this on monday.. but there were so many other stuff to do along with this.. and i did try referring up the Calendar utility but it was a bit confusing actually.. it was only after that did i come to this forum.. nor am i very good at Java.. anyhoo thanks for your sympathies :P

  • How to get the difference between two date

    Hello,
    I want to know how to write a code the tell me the difference between two date, I am using
    oracle.jbo.domain.Date
    i have a rent date and return date so my code is
    Date rent=(Date)nr.getAttrbute("RentDate"),ret=(Date)nr.getAttrbute("ReturnDate");
    is there a way to know the difference in days between those two dates ?
    Thanks

    hi,
    try this.....
    DateFormat formatter = new SimpleDateFormat("E MMM dd HH:mm:ss Z yyyy");
    Date date = (Date)formatter.parse(dateStr); //// dateStr <- from date value (that is string value)
    Date dateto = (Date)formatter.parse(datetostr); //// datetostr <- to date value (to date getting from as a string)
    Calendar cal = Calendar.getInstance();
    cal.setTime(date);
    Calendar calto = Calendar.getInstance();
    calto.setTime(dateto);
    fromDate = cal.get(Calendar.DATE) + "/" + (cal.get(Calendar.MONTH) + 1) + "/" + cal.get(Calendar.YEAR);
    toDate = calto.get(Calendar.DATE) + "/" + (calto.get(Calendar.MONTH) + 1) + "/" + calto.get(Calendar.YEAR);
    // System.out.println("from Date : " + fromDate);
    if ((fromDate != null && toDate != null) && (date.compareTo(dateto) > -1) ) {                  
    fc.addMessage("VacationQueryComponent", new FacesMessage(FacesMessage.SEVERITY_ERROR, "From Date cannot be lower than To Date", "From Date cannot be lower than To Date"));
    fc.renderResponse();
    thks.

  • Difference between two date in bex query

    Hi all,
    I need to do a difference between two date using formula variable processing type customer exit beaucause I must use factory calendar in the formula.
    How can I do it?
    Can you give me an example of the routine?
    Thanks a lot
    Gianmarco

    Hi,
    You can still use the same code to copy it and customize as per your need. All you need to do is to subract the dates using the class: CL_ABAP_TSTMP after converting to timestamp and resulting seconds you convert back to days....Please get help from the developers to do this...
    Also, ensure that you write back this difference value to your variable so you get it on the reports for your calculations...
    Cheers,
    Emmanuel.

  • How can i get report between two dates?

    Hi
    how can i get report between two dates?
    for example i want get reports between 20/4/2002 & 27/4/2002.
    my table has date column and i can get first date( exam : .... where date:=a and/or ....i don't know this part)
    thanks alot.
    Regards
    The Oracle Reports Team
    http://otn.oracle.com/

    where exam_date between :from_date and :to_date
    from_date and to_date are user_parameter

  • Difference between two date ,according to office time.

    hi,
    How can I get diffrence between two date.
    If I select from-date  20-03-2012 09:30AM and to-date 20-03-2012 06:30PM then output should be 1 day(as it is office time from 09:30 AM TO 06:30 PM).
    ACCORDINGLY If I select from-date  20-03-2012 09:30AM and to-date 21-03-2012 02:00PM then output should be 1.5 day
    select 24*(to_date(:P2_TO_DATE,'DD-MM-YYYY HH:MIPM') - to_date(:P2_FROM_DATE,'DD-MM-YYYY HH:MIPM'))"date" from dual;

    Hello Shirish,
    WITH dates AS(
        SELECT  TO_DATE ('20-03-2012 09:30AM', 'DD-MM-YYYY HH:MIPM') AS start_date
               ,TO_DATE ('20-03-2012 06:30PM', 'DD-MM-YYYY HH:MIPM') AS end_date
        FROM    dual
        UNION ALL
        SELECT  TO_DATE ('20-03-2012 09:30AM', 'DD-MM-YYYY HH:MIPM') AS start_date
               ,TO_DATE ('20-03-2012 04:15PM', 'DD-MM-YYYY HH:MIPM') AS end_date
        FROM    dual
        UNION ALL
        SELECT  TO_DATE ('20-03-2012 09:30AM', 'DD-MM-YYYY HH:MIPM') AS start_date
               ,TO_DATE ('21-03-2012 02:00PM', 'DD-MM-YYYY HH:MIPM') AS end_date
        FROM    dual
        UNION ALL
        SELECT  TO_DATE ('20-03-2012 09:30AM', 'DD-MM-YYYY HH:MIPM') AS start_date
               ,TO_DATE ('21-03-2012 12:00PM', 'DD-MM-YYYY HH:MIPM') AS end_date
        FROM    dual
        UNION ALL
        SELECT  TO_DATE ('20-03-2012 04:30PM', 'DD-MM-YYYY HH:MIPM') AS start_date
               ,TO_DATE ('21-03-2012 02:00PM', 'DD-MM-YYYY HH:MIPM') AS end_date
        FROM    dual
        UNION ALL
        SELECT  TO_DATE ('20-03-2012 04:30PM', 'DD-MM-YYYY HH:MIPM') AS start_date
               ,TO_DATE ('22-03-2012 02:00PM', 'DD-MM-YYYY HH:MIPM') AS end_date
        FROM    dual
        UNION ALL
        SELECT  TO_DATE ('20-03-2012 04:30PM', 'DD-MM-YYYY HH:MIPM') AS start_date
               ,TO_DATE ('22-03-2012 10:00AM', 'DD-MM-YYYY HH:MIPM') AS end_date
        FROM    dual
    ,times as(
    SELECT  start_date
           ,end_date
           ,TRUNC (end_date - start_date) days
           ,MOD (end_date - start_date,1) hours
           ,(start_date - 9.5/24 - TRUNC (start_date))*24 offset_start
           ,(end_date - 9.5/24 - TRUNC (end_date))*24 offset_end
           ,(end_date - 9.5/24 - TRUNC (end_date))*24
            - (start_date - 9.5/24 - TRUNC (start_date))*24 offset_diff
    FROM    dates
    SELECT  TO_CHAR(start_date, 'DD-MM-YYYY HH:MIPM') AS start_date
           ,TO_CHAR(end_date, 'DD-MM-YYYY HH:MIPM') AS end_date
           ,days
           ,ROUND(offset_start,2) offset_start
           ,ROUND(offset_end,2) offset_end
           ,ROUND(offset_diff,2) offset_diff
           ,CASE WHEN offset_diff > 4 THEN
                days + 1
            WHEN offset_diff > 0 THEN
                days + 0.5
            WHEN offset_diff = 0 THEN
                days
            WHEN offset_diff + 9 > 4 THEN
                days + 1
            ELSE
                days + 0.5
            END computed_days
    FROM  timesThe first step (subquery times) computes the full days and the difference between start_date and end_date, compared to the beginning of the office ours (9.5 /24)
    The second step takes the days and according to the possible values of the difference adds a half or a full day.
    Regards
    Marcus
    Edited by: Marwim on 19.03.2012 11:23
    CASE offset_diff = 0

  • Date difference between two dates

    hi All,
    i have to right a stored proc to find the difference between two dates. 
    for example of i give
    startdate as 4/1/2015 and enddate 14/1/2015
    i should get 1 year , 10 days and 0 months .
    i have tried the DateDiff function but it does not calculate the leap year.
    please help.

    DECLARE @from datetime
    DECLARE @to   datetime
    SET @from = '20150104  8:00'
    SET @to   = '20150114  10:30'
    SELECT DATEDIFF(minute,@from, @to) % 60 as Minutes
    SELECT (DATEDIFF(minute,@from, @to) / 60) % 24 as Hours
    SELECT DATEDIFF(minute,@from, @to) / (60 * 24) as Days
    SELECT DATEDIFF(month,@from, @to) as Months
    SELECT DATEDIFF(year,@from, @to) as Year
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Difference between two dates

    Hi
    I have two date fields in the ODS..Both are characterists
    1. Requested delivery date
    2. Actual shipment end date.
    I would like to create a calculated KF  field for the difference between two dates in a query.
    How can I accomplish it?
    Regards

    You have to make Expiration data as nav attribute and create a formula variable then only this date can be used in calculations.
    refer this How to...for the same
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/72f4a790-0201-0010-5b89-a42a32223ffc
    later you can try to calculate difference between dates!
    Re: calculating the difference between two dates
    Please search in forum with 'difference between two dates'.You will find lots of good posts on this issue!
    hope this helps
    Regards

  • Calculate the Difference Between two dates excluding weekends and Holidays

    Hi,
    We need to calculate the difference between the two dates by excluding the Local public holidays (It is global and varies across countries) and weekends should not be included in calculation for a business day in OBIEE.
    We have two dates: Open date and close date when ever close date is null we are calculating age based on taking the current timestamp and need to exclude the weekends and Holidays when ever the close date is null.
    Ex:
    Col1 col2 Total
    11/9/2010 2:46:38 PM Null 13
    11/2/2010 8:06:26 PM 11/3/2010 5:37:03 PM 1
    (In the Total we shouldn't include the weekends,holidays)
    Please let me know how to calculate the difference between two dates by excluding the weekends and holidays.
    Thanks
    Edited by: user10441472 on Nov 22, 2010 3:14 PM

    You already asked this question and I answered it...
    Re: calculation of Business day in OBIEE

  • To find difference between two dates

    Hi all,
    I am new to this forum and oracle.
    I want to get the difference between two dates. My query is as below...
    sqlserver_utilities.datediff('YY', startdate,enddate)
    I want the difference in year.
    Please help me. It's really urgent.
    Thanks in advance.
    Regards,
    Inam

    Select to_char(enddate,'YY') - to_char(startdate,'YY') fromPLEASE don't do that. There are so many things wrong with it...
    for example:
    1). Why are you subtracting character data types?
    2). What if the start date is 1999 and the end date is 2000? Do you expect to get a difference of -1?
    3). What if the start date is 1 Jan 2000 and the end date is 31 Dec 2000? Do you expect to get 0 instead of 1 or .997?
    4). Why would you convert dates to something else when they are inherently subtractable.
    5). There are obvious points in the OP's "specification" that are vague - the best thing (after telling them to search, of course since this has been answered a million times already) would be to try to clarify the spec.
    John

  • As to the data type of the data type of the difference between two date type of datas

    Hi,
    I have a question about the data type of the difference between two date type of datas.
    There are two date type of datas as:
    SSHIPMENTS.RECEIVEDATETIME
    SSHIPMENTS.PROMISEDATETIME
    I try to use the following SQL Script in Oracle SQL*Plus as:
    SELECT CASE
    WHEN (SSHIPMENTS.RECEIVEDATETIME - SSHIPMENTS.PROMISEDATETIME) < '000 01:00:00.000' THEN 'OnTime'
    WHEN (SSHIPMENTS.RECEIVEDATETIME - SSHIPMENTS.PROMISEDATETIME) < '000 01:30:00.000' THEN '60-89 Minutes'
    ELSE '3+ Hours'
    END
    FROM SSHIPMENTS;
    The error message of "Invalid Number" for the '000 01:30:00.000' happens.
    I don't know if the data type of the interval is wrong.
    Many Thanks,
    Cathy

    SELECT CASE
    WHEN (to_char(SSHIPMENTS.RECEIVEDATETIME,'hhmiss') - to_char(SSHIPMENTS.PROMISEDATETIME,'hh24miss')) < '010000' THEN 'OnTime'
    WHEN (to_char(SSHIPMENTS.RECEIVEDATETIME,'hhmiss') - to_char(SSHIPMENTS.PROMISEDATETIME,'hh24miss'))< '000 01:30:00.000' THEN '60-89 Minutes'
    ELSE '3+ Hours'
    END
    FROM SSHIPMENTS;
    just try it out..

  • How can get difference between 2 dates in the form of days

    how can get difference between 2 dates in the form of days

    Hi,
    Check the following program:
    REPORT ZDATEDIFF.
    DATA: EDAYS   LIKE VTBBEWE-ATAGE,
          EMONTHS LIKE VTBBEWE-ATAGE,
          EYEARS  LIKE VTBBEWE-ATAGE.
    PARAMETERS: FROMDATE LIKE VTBBEWE-DBERVON,
                TODATE   LIKE VTBBEWE-DBERBIS DEFAULT SY-DATUM.
    call function 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
      exporting
        i_date_from          = FROMDATE
        i_date_to            = TODATE
      I_FLG_SEPARATE       = ' '
      IMPORTING
        E_DAYS               = EDAYS
        E_MONTHS             = EMONTHS
        E_YEARS              = EYEARS.
    WRITE:/ 'Difference in Days   ', EDAYS.
    WRITE:/ 'Difference in Months ', EMONTHS.
    WRITE:/ 'Difference in Years  ', EYEARS.
    INITIALIZATION.
    FROMDATE = SY-DATUM - 60.
    Regards,
    Bhaskar

Maybe you are looking for

  • Help in loading a .jad file

    Hello everyone, I downloaded a couple of ".jad" files on my BB Playbook (32GB ). Is there a way to either load or run the files. They are named; "BrownApocalypseDemo.jad & Chatbuddie9jawap.jad". I used the "Air Browser" app to attempt to view/load th

  • Getting the following error while running the apex 3.2 report

    Hello All, I am running apex 3.2 on oracle 10g. I am getting the following error .. ORA-04030: out of process memory when trying to allocate 16328 bytes (koh-kghu call ,pl/sql vc2) Pls let me know what's the cause of this error.. thanks/kumar

  • Interfaces in Oracle Apps

    Hi Where can i find tutorials for Interfaces in Oracle Apps.. Thanks Binu

  • BAPI for Price Change using Transaction VK12

    Hi All.. Can any one help in locating a BAPI for making price changes using transaction VK12. Rgds

  • Mailing list set-up in OS X Server.

    Dear members: I have been looking at different options for setting up a few mailing list groups. One of the best options I have found in terms of functionality and features is Listserv software but it is very expensive and is only available in a Unix