Calculation between two date time

hi,
This is my table structure :
In_time Date;
Out_time Date;
Duration Number;
user enter the In_time and Out time data is 12:30 like this ( HH24:mi format).
for Example
In_time Out_time duration
12.30 2.00 1:30
I want to store the difference b/w In_time and Out_time to be insert in the duration column;

:out_time - :in_time is duration in days, if both items are of type date or datetime.
but why are you storing redundant data?
in_time and duration OR in_time and out_time is enough ...

Similar Messages

  • Calculate difference between two dates/times

    Hi all,
    Is there any function module to calculate difference between two dates/times which are in TIMESTAMPL format.
    I need to know how many millisconde(second,minutes, hours... )there is between these two times.
    Please, It is urgent
    Thank you all.
    Karim

    hi,
    try the following function
    CALL FUNCTION 'CCU_TIMESTAMP_DIFFERENCE'        
          EXPORTING                                  
               timestamp1 = timestamp1               
               timestamp2 = timestamp2               
          IMPORTING                                  
               difference = diff                     
          EXCEPTIONS                                 
               OTHERS     = 1. 
    the above function gives the difference in seconds...
    try the following  code to set the resolution to milliseconds..
    SET RUN TIME CLOCK RESOLUTION LOW
    check the thread for details:
    SET RUN TIME CLOCK RESOLUTION?
    all the best!!!
    Regards,
    Aparna

  • Calculate the difference between two dates times in infopath form 2013

    Hi,
    I have an infopath 2013 form that contains three fields:
    2 date time and the 3rd contains the difference between the two in hours
    how I can make the difference between the two so that the display will be like this:
    Date Time1           08/21/2014           22:00 
    Date Time2           08/22/2014           1:00
    Diff Field                                             3:00

    Hi,
    Please refer to the following article which matches your requirement exactly.
    Calculate the difference between two date picker controls in InfoPath using rules and formulas - no code!
    Please mark it answered, if your problem resolved.

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

  • 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

  • Calculation of MONTHS , YEARS , & DAYS between two dates

    Hi Experts,
      Currently i am using this functional Module. which calculates the number of months between two dates.
       CALL FUNCTION 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
             EXPORTING
                  I_DATE_FROM = ITAB_PER-BEGDA
                  I_DATE_TO   = ITAB_PER-ENDDA
             IMPORTING
                  E_MONTHS    = CMONTHS.
      BUT this functional module Rounding off the Month...Say ..if the total numbr of days between from & to date is 105 it is showing as 4 months ...
      <b>Is there any other Functional Module</b> ????which Calculates the EXACT MONTH between two dates...(in the above case the month is expected to be 3 only since it is 105 days only)..
      Kindly help me regarding this....

    lakshimiraja,
    You can use this function module.
    report zrich_0003
           no standard page heading.
    data: duration_in_months type i.
    parameters: s_date type sy-datum,
                e_date type sy-datum.
    call function 'DURATION_DETERMINE'
    exporting
       unit                             = 'MON'
       factory_calendar                 = 'P6'    "  Your factory calendar
    importing
       duration                         = duration_in_months
    changing
       start_date                       = s_date
       end_date                         = e_date
    exceptions
       factory_calendar_not_found       = 1
       date_out_of_calendar_range       = 2
       date_not_valid                   = 3
       unit_conversion_error            = 4
       si_unit_missing                  = 5
       parameters_not_valid             = 6
       others                           = 7.
       write:/ duration_in_months.
    Don't forget to reward if useful...

  • Difference between two dates: a complete solution

    There have been many posts asking how to get the number of days between two dates. There is no method in java like the VB method dateDiff(), and there is only the method date.getTime() which gives you the number of milliseconds since Jan 1 1970, the Epoch. I have not seen a solution that makes use of the fact that there are 86400000 milliseconds per day, only when trying to get the number of days , i.e. multiples of 24 hours between two millisecond points in time.
    So what if date1 was Oct 26th 11.30pm and date2 was Oct 27th 12.30am? If you get the millisecond difference, and divide by 86400000, you do not notice that these two times are on separate days, but only one hour apart.
    My solution takes account of the modulo (%) function. If you use the date.getTime() method, and use % 86400000 on this number of milliseconds, it will tell you how far (milliseconds) this date is into this day, after 12am. If you subtract this amount from the total number of milliseconds, then divide by 86400000, this will give you the number of days after the Epoch, so you are able to know which day the millisecond time is in. If you want to know the days between two millisecond times, this will tell you, whereas just dividing by 86400000, will not, and may be misleading.
    I think this could be incorporated into the Date class easily. There are some problems though, as not every day has 86400000 milliseconds, if you are talking about days when Daylight Saying Time begins or ends. Doing calculations like that will create errors, unless you know whether each date is in Daylight Saving Time or not. Leap years are OK, unless want to work out the number of years from the number of days by dividing by 365, as calculating numbers of days is only done by looking at a 24 hour time period. However where 'leap seconds' have been added, like once every ten years, there may be small errors. This was not included in anyone elses calculations.
    So the calculation would go like this:
    public class BetterDate extends Date
    public int dayDifference(Date d)
    long time = this.getTime() ; // gets milliseconds
    long timed = d.getTime() ; // gets milliseconds of other date
    int days = (time - (time % 86400000))/86400000 ; // number of days
    int daysd = (timed - (timed % 86400000))/86400000 ; // number of days of other date
    int difference = daysd - days ; // difference in days between two dates
    return difference ;
    If you want you can use the value (time % 86400000), and modulo this amount with the number of milliseconds in one hour, then subtract the result from the (time % 86400000) and divide by the millliseconds in one hour to give you the number of hours, but there are JDK functions that you can use to get the hour if needed.
    This method is not perfect, but for most cases will get you the difference in days between two dates.
    James

    Hi James,
    I tried out your solution, but it seems to fail on dates without times. I tries the difference between 31/03/2002 and 01/04/2002 and the result is 0. I guess it is because the times are assumed to be 00:00 as no times are mentioned and 31st March I believe is the date when DST change will take place this year. If I set the two times as well to a time much later than midnight for example 0600 then I seem to get the right answer.
    Joag
    There have been many posts asking how to get the
    number of days between two dates. There is no method
    in java like the VB method dateDiff(), and there is
    only the method date.getTime() which gives you the
    number of milliseconds since Jan 1 1970, the Epoch. I
    have not seen a solution that makes use of the fact
    that there are 86400000 milliseconds per day, only
    when trying to get the number of days , i.e. multiples
    of 24 hours between two millisecond points in time.
    So what if date1 was Oct 26th 11.30pm and date2 was
    Oct 27th 12.30am? If you get the millisecond
    difference, and divide by 86400000, you do not notice
    that these two times are on separate days, but only
    one hour apart.
    My solution takes account of the modulo (%) function.
    If you use the date.getTime() method, and use %
    86400000 on this number of milliseconds, it will tell
    you how far (milliseconds) this date is into this day,
    after 12am. If you subtract this amount from the total
    number of milliseconds, then divide by 86400000, this
    will give you the number of days after the Epoch, so
    you are able to know which day the millisecond time is
    in. If you want to know the days between two
    millisecond times, this will tell you, whereas just
    dividing by 86400000, will not, and may be
    misleading.
    I think this could be incorporated into the Date class
    easily. There are some problems though, as not every
    day has 86400000 milliseconds, if you are talking
    about days when Daylight Saying Time begins or ends.
    Doing calculations like that will create errors,
    unless you know whether each date is in Daylight
    Saving Time or not. Leap years are OK, unless want to
    work out the number of years from the number of days
    by dividing by 365, as calculating numbers of days is
    only done by looking at a 24 hour time period. However
    where 'leap seconds' have been added, like once every
    ten years, there may be small errors. This was not
    included in anyone elses calculations.
    So the calculation would go like this:
    public class BetterDate extends Date
    public int dayDifference(Date d)
    long time = this.getTime() ; // gets milliseconds
    long timed = d.getTime() ; // gets milliseconds of
    other date
    int days = (time - (time % 86400000))/86400000 ; //
    number of days
    int daysd = (timed - (timed % 86400000))/86400000 ; //
    number of days of other date
    int difference = daysd - days ; // difference in days
    between two dates
    return difference ;
    If you want you can use the value (time % 86400000),
    and modulo this amount with the number of milliseconds
    in one hour, then subtract the result from the (time %
    86400000) and divide by the millliseconds in one hour
    to give you the number of hours, but there are JDK
    functions that you can use to get the hour if needed.
    This method is not perfect, but for most cases will
    get you the difference in days between two dates.
    James

  • Number of occurences between two dates based on a starting date + frequence

    I have a starting date in cell A1 and a frequency (in days) in cell B1. In cell C1 I have a date (begin) and in cell C4 I have a later date (end). I need to know how often the event occurs during the time between begin and end dates (inclusive).
    For instance, the starting date is january 25th, the frequency is 5. The first date is januari 25th, the second date is februari 12th. The result should be 2 (because given the starting date and frequency of the event, it will occur in februari on day 4 and 9).
    I have been looking at some of the statistical functions, but I don't think there is a function for this. Right now I have about 5 formulas to calculate intermediate results, but I'm stuck trying to combine them.
    I would be happy with just a pointer in the right direction. For instance, is there a specific name for this kind of calculation?

    michielvoo wrote:
    I have a starting date in cell A1 and a frequency (in days) in cell B1. In cell C1 I have a date (begin) and in cell C4 I have a later date (end). I need to know how often the event occurs during the time between begin and end dates (inclusive).
    For instance, the starting date is january 25th, the frequency is 5. The first date is januari 25th, the second date is februari 12th. The result should be 2 (because given the starting date and frequency of the event, it will occur in februari on day 4 and 9).
    If the event occurs every five days, the second date will be January 30, and the event will occur four times " during the time between begin and end dates (inclusive)"
    I have been looking at some of the statistical functions, but I don't think there is a function for this. Right now I have about 5 formulas to calculate intermediate results, but I'm stuck trying to combine them.
    It's not really a statistical calculation, but a simple division to find "How many whole sets of five (days) are there in the days between two dates."
    I would be happy with just a pointer in the right direction. For instance, is there a specific name for this kind of calculation?
    Two functions and one operation are needed:
    DATEDIF() to calculate the number of days between the start and end dates.
    Division to determine how many sets of five days there are in that period.
    INT() to discard the fractional part of the result.
    With the values located as described, this formula (placed in a cell on the same table) will return the number of occurrences not including the first one.
    =INT(DATEDIF(C1,C4,"D")/B1)
    To include the Start date as one of the occurrences, make this modification:
    =INT(DATEDIF(C1,C4,"D")/B1)+1
    Regards,
    Barry

  • 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

  • How to substract two date&time values

    Well,i just need to substract last visited date&time value from systemdate. The last visited date&time(from the filed named SONBULUNMAZAMANI, ) is selected from table (IHALE_KATILIMCILAR ) in the format DD-MM-RRRR HH24:MI and systemdate is in the same format. And i need to get value in minutes. Then i need to check if the value is greater then 20 minutes, finally i will update database and set IHALE_KATILIMCILAR.AKTIF=0. Here is the code i used;
    DECLARE
    MinDiff number;
    DateTime1 ihale_katilimcilar.sonbulunmazamani%TYPE;
    BEGIN
    select t.sonbulunmazamani into DateTime1 from ihale_katilimcilar t where t.ihlkodu=141 and t.ihlaltktgkodu=132 and t.id_iliski=193;
    MinDiff := ABS( TO_DATE( TO_CHAR(SYSDATE, 'DD-MM-RRRR') || TO_CHAR(SYSDATE , 'HH24:MI'), 'DD-MM-RRRR HH24:MI' ) - TO_DATE( TO_CHAR(DateTime1, 'DD-MM-RRRR') || TO_CHAR(DateTime1, 'HH24:MI'), 'DD-MM-RRRR HH24:MI' ) );
    DBMS_OUTPUT.PUT_LINE('Difference is ' || MinDiff);
    END;
    However the result i get is always pointed values such as ,1895833333333333333333333333333333333333. How can i handle this?
    And here is the scripts of table:
    create table IHALE_KATILIMCILAR
    KULADI VARCHAR2(20),
    SONUC NUMBER(1),
    AKTIF NUMBER(1) default 1,
    SRKTKODU VARCHAR2(10) not null,
    SONBULUNMAZAMANI DATE default sysdate,
    SIRA NUMBER(1) default 0,
    MESAJ VARCHAR2(200),
    ID NUMBER(6) not null,
    IHLKODU NUMBER not null,
    IHLALTKTGKODU VARCHAR2(10) not null,
    ID_ILISKI NUMBER,
    IHLSIRA NUMBER(1) default 0,
    CEVAP VARCHAR2(200)
    insert into IHALE_KATILIMCILAR (KULADI, SONUC, AKTIF, SRKTKODU, SONBULUNMAZAMANI, SIRA, MESAJ, ID, IHLKODU,
    IHLALTKTGKODU, ID_ILISKI, IHLSIRA, CEVAP)
    values ('asd', null, 1, '4444', to_date('19-02-2008 10:29:44', 'dd-mm-yyyy hh24:mi:ss'), 0, 'süre talep 2', 76, 145,
    '135', 345, 0, 'al sna süre 77');
    insert into IHALE_KATILIMCILAR (KULADI, SONUC, AKTIF, SRKTKODU, SONBULUNMAZAMANI, SIRA, MESAJ, ID, IHLKODU,
    IHLALTKTGKODU, ID_ILISKI, IHLSIRA, CEVAP)
    values ('asd', null, 1, '4444', to_date('20-02-2008 14:49:52', 'dd-mm-yyyy hh24:mi:ss'), 0, null, 77, 145, '135',
    345, 0, null);
    insert into IHALE_KATILIMCILAR (KULADI, SONUC, AKTIF, SRKTKODU, SONBULUNMAZAMANI, SIRA, MESAJ, ID, IHLKODU,
    IHLALTKTGKODU, ID_ILISKI, IHLSIRA, CEVAP)
    values ('asd', null, 1, '4444', to_date('19-02-2008 10:29:44', 'dd-mm-yyyy hh24:mi:ss'), 0, null, 78, 145, '135',
    345, 0, null);
    insert into IHALE_KATILIMCILAR (KULADI, SONUC, AKTIF, SRKTKODU, SONBULUNMAZAMANI, SIRA, MESAJ, ID, IHLKODU,
    IHLALTKTGKODU, ID_ILISKI, IHLSIRA, CEVAP)
    values ('asd', null, 1, '4444', to_date('19-02-2008 10:29:44', 'dd-mm-yyyy hh24:mi:ss'), 0, null, 79, 145, '135',
    345, 0, null);
    insert into IHALE_KATILIMCILAR (KULADI, SONUC, AKTIF, SRKTKODU, SONBULUNMAZAMANI, SIRA, MESAJ, ID, IHLKODU,
    IHLALTKTGKODU, ID_ILISKI, IHLSIRA, CEVAP)
    values ('KEMMM', null, 0, '42', to_date('17-03-2008 09:29:20', 'dd-mm-yyyy hh24:mi:ss'), 0, null, 63, 141, '134',
    191, 0, null);
    insert into IHALE_KATILIMCILAR (KULADI, SONUC, AKTIF, SRKTKODU, SONBULUNMAZAMANI, SIRA, MESAJ, ID, IHLKODU,
    IHLALTKTGKODU, ID_ILISKI, IHLSIRA, CEVAP)
    values ('MLK', null, 1, '46', to_date('07-03-2008 09:52:20', 'dd-mm-yyyy hh24:mi:ss'), 0, null, 64, 141, '134', 192,
    0, null);
    insert into IHALE_KATILIMCILAR (KULADI, SONUC, AKTIF, SRKTKODU, SONBULUNMAZAMANI, SIRA, MESAJ, ID, IHLKODU,
    IHLALTKTGKODU, ID_ILISKI, IHLSIRA, CEVAP)
    values ('KEM.ESM', null, 1, '44', to_date('06-03-2008 13:28:50', 'dd-mm-yyyy hh24:mi:ss'), 0, null, 61, 145, '135',
    189, 0, null);
    insert into IHALE_KATILIMCILAR (KULADI, SONUC, AKTIF, SRKTKODU, SONBULUNMAZAMANI, SIRA, MESAJ, ID, IHLKODU,
    IHLALTKTGKODU, ID_ILISKI, IHLSIRA, CEVAP)
    values ('KE.ES', null, 1, '45', to_date('07-03-2008 11:16:41', 'dd-mm-yyyy hh24:mi:ss'), 0, null, 69, 141, '133',
    197, 0, null);
    insert into IHALE_KATILIMCILAR (KULADI, SONUC, AKTIF, SRKTKODU, SONBULUNMAZAMANI, SIRA, MESAJ, ID, IHLKODU,
    IHLALTKTGKODU, ID_ILISKI, IHLSIRA, CEVAP)
    values ('KEMMM', null, 0, '42', to_date('17-03-2008 09:29:20', 'dd-mm-yyyy hh24:mi:ss'), 0, null, 65, 141, '132',
    193, 1, null);
    insert into IHALE_KATILIMCILAR (KULADI, SONUC, AKTIF, SRKTKODU, SONBULUNMAZAMANI, SIRA, MESAJ, ID, IHLKODU,
    IHLALTKTGKODU, ID_ILISKI, IHLSIRA, CEVAP)
    values ('KE.ES', null, 1, '45', to_date('07-03-2008 11:16:41', 'dd-mm-yyyy hh24:mi:ss'), 2, null, 66, 141, '132',
    194, 1, null);
    insert into IHALE_KATILIMCILAR (KULADI, SONUC, AKTIF, SRKTKODU, SONBULUNMAZAMANI, SIRA, MESAJ, ID, IHLKODU,
    IHLALTKTGKODU, ID_ILISKI, IHLSIRA, CEVAP)
    values ('MLK', null, 1, '46', to_date('07-03-2008 09:52:20', 'dd-mm-yyyy hh24:mi:ss'), 0, null, 67, 141, '132', 195,
    1, null);
    insert into IHALE_KATILIMCILAR (KULADI, SONUC, AKTIF, SRKTKODU, SONBULUNMAZAMANI, SIRA, MESAJ, ID, IHLKODU,
    IHLALTKTGKODU, ID_ILISKI, IHLSIRA, CEVAP)
    values ('KEMMM', null, 0, '42', to_date('17-03-2008 09:29:20', 'dd-mm-yyyy hh24:mi:ss'), 0, null, 68, 141, '133',
    196, 0, null);
    insert into IHALE_KATILIMCILAR (KULADI, SONUC, AKTIF, SRKTKODU, SONBULUNMAZAMANI, SIRA, MESAJ, ID, IHLKODU,
    IHLALTKTGKODU, ID_ILISKI, IHLSIRA, CEVAP)
    values ('KEM.ESM', null, 1, '44', to_date('12-03-2008 15:00:58', 'dd-mm-yyyy hh24:mi:ss'), 0, null, 70, 142, '252',
    198, 1, null);
    insert into IHALE_KATILIMCILAR (KULADI, SONUC, AKTIF, SRKTKODU, SONBULUNMAZAMANI, SIRA, MESAJ, ID, IHLKODU,
    IHLALTKTGKODU, ID_ILISKI, IHLSIRA, CEVAP)
    values ('KE.ES', null, 1, '45', to_date('10-03-2008 10:08:17', 'dd-mm-yyyy hh24:mi:ss'), 0, null, 71, 142, '252',
    199, 1, null);
    insert into IHALE_KATILIMCILAR (KULADI, SONUC, AKTIF, SRKTKODU, SONBULUNMAZAMANI, SIRA, MESAJ, ID, IHLKODU,
    IHLALTKTGKODU, ID_ILISKI, IHLSIRA, CEVAP)
    values ('KEM.ESM', null, 1, '44', to_date('10-03-2008 10:08:56', 'dd-mm-yyyy hh24:mi:ss'), 0, null, 72, 143, '253',
    200, 1, null);
    insert into IHALE_KATILIMCILAR (KULADI, SONUC, AKTIF, SRKTKODU, SONBULUNMAZAMANI, SIRA, MESAJ, ID, IHLKODU,
    IHLALTKTGKODU, ID_ILISKI, IHLSIRA, CEVAP)
    values ('MLK', null, 1, '46', to_date('12-02-2008 13:34:40', 'dd-mm-yyyy hh24:mi:ss'), 0, null, 73, 143, '253', 201,
    1, null);
    insert into IHALE_KATILIMCILAR (KULADI, SONUC, AKTIF, SRKTKODU, SONBULUNMAZAMANI, SIRA, MESAJ, ID, IHLKODU,
    IHLALTKTGKODU, ID_ILISKI, IHLSIRA, CEVAP)
    values ('KE.ES', null, 1, '45', to_date('06-03-2008 14:09:40', 'dd-mm-yyyy hh24:mi:ss'), 0, null, 60, 145, '136',
    188, 1, null);
    insert into IHALE_KATILIMCILAR (KULADI, SONUC, AKTIF, SRKTKODU, SONBULUNMAZAMANI, SIRA, MESAJ, ID, IHLKODU,
    IHLALTKTGKODU, ID_ILISKI, IHLSIRA, CEVAP)
    values ('KEM.ESM', null, 1, '44', to_date('06-03-2008 13:28:50', 'dd-mm-yyyy hh24:mi:ss'), 0, null, 74, 145, '136',
    202, 1, null);
    insert into IHALE_KATILIMCILAR (KULADI, SONUC, AKTIF, SRKTKODU, SONBULUNMAZAMANI, SIRA, MESAJ, ID, IHLKODU,
    IHLALTKTGKODU, ID_ILISKI, IHLSIRA, CEVAP)
    values ('KE.ES', null, 1, '45', to_date('06-03-2008 14:09:40', 'dd-mm-yyyy hh24:mi:ss'), 0, null, 75, 145, '135',
    203, 0, null);
    Thanks...

    What version of SQLServer do you have? Datediff is not an Oracle built-in function.
    OP:
    THe difference between two dates in Oracle is in days. The decimal portion refers to partial days, so you need to convert that to the required precision. Also, both sysdate and your column are date type, and contain a time portion, so you do not need all the to_date/to_char stuff. Something like:
    SQL> SELECT end_dt, start_dt, (end_dt - start_dt) * 24*60 diff
      2  FROM (SELECT sysdate end_dt, TRUNC(sysdate) start_dt
      3        FROM dual);
    END_DT             START_DT                 DIFF
    17-mar-08 10:39:39 17-mar-08 00:00:00     639.65John

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

  • Using pl/sql function for each day between two dates.

    Hi,
    create TABLE EMP(
    ID_EMP NUMBER,
    DT_FROM DATE,
    DT_TO DATE,
    CREATE_DATE DATE);
    into EMP(ID_EMP, DT_FROM, DT_TO, CREATE_DATE)
    Values(100, TO_DATE('07/01/2008 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('04/30/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'),TO_DATE('05/08/2009 14:11:21', 'MM/DD/YYYY HH24:MI:SS'));
    I have a function called  elig_pay_dates(date p_date), which returns the code for  person payment eligibility for a particular date. For paid dates it's 'P' and for unpaid dates it's 'N'.
    How can I check this function between two dates for each day. Example : 07/01/2008 to 04/30/2010.
    By using this function with select I needs to display the dates when there is a change in status.
    I am expecting data in following manner from above logic(this is example):
    07/01/2008 --- 07/01/2009 ---'P'
    07/02/2009 -- 07/25/2009 ----'N'
    07/26/2009 -- 01/01/2010 ---'P'
    01/02/2010 -- 01/13/2010 --'N'
    01/14/2010 -- 01/18/2010 --'P'
    01/19/2010 -- 04/30/2010 -- 'N'
    I thought of looping for each day date but that seems to be expensive for online application. Is there any way that I can achieve this requirement with sql query ?
    Thanks for your help,

    Certainly not the best way to code the requirement, but it does achieve the result you are looking for in a fairly quick time
    create or replace
    function test_ret_paid_unpaid (p_date in date)
    return varchar2
    is
      v_ret     varchar2(1);
    begin
      if ( (p_date between to_date('07/02/2009', 'MM/DD/YYYY') and to_date('07/25/2009', 'MM/DD/YYYY') ) or
           (p_date between to_date('01/02/2010', 'MM/DD/YYYY') and to_date('01/13/2010', 'MM/DD/YYYY') ) or
           (p_date between to_date('01/19/2010', 'MM/DD/YYYY') and to_date('04/30/2010', 'MM/DD/YYYY') )
        then v_ret := 'N';
      else
        v_ret := 'Y';
      end if;
      return v_ret;
    end;
    Wrote file afiedt.buf
      1  with get_paid_unpaid as
      2  (
      3    select dt_from start_date, dt_to end_date, dt_from + level - 1 curr_date, test_ret_paid_unpaid(dt_from + level - 1) paid_unpaid,
      4           row_number() over (order by dt_from + level - 1) rn_start,
      5           row_number() over (order by dt_from + level - 1 desc) rn_end
      6      from test_emp
      7    connect by level <= dt_to - dt_from + 1
      8  ),
      9  get_stop_date as
    10  (
    11  select start_date init_date, end_date, curr_date, paid_unpaid,
    12         case when paid_unpaid != lag(paid_unpaid) over (order by curr_date) or rn_start = 1 or rn_end = 1
    13          then curr_date
    14          else null
    15         end start_date,
    16         case when paid_unpaid != lead(paid_unpaid) over (order by curr_date) or rn_start = 1 or rn_end = 1
    17          then curr_date
    18          else null
    19         end stop_date
    20    from get_paid_unpaid
    21  )
    22  select period, paid_unpaid
    23    from (
    24  select init_date, curr_date, start_date, end_date, stop_date,
    25         case when paid_unpaid = lead(paid_unpaid) over (order by curr_date)
    26                then nvl(start_date, init_date) || ' - ' || lead(stop_date, 1, end_date) over (order by curr_date)
    27              else null
    28         end period,
    29         paid_unpaid
    30    from get_stop_date
    31   where stop_date is not null or start_date is not null
    32         )
    33*  where period is not null
    12:06:10 SQL> /
    PERIOD                                             PAID_UNPAID
    01-JUL-08 - 01-JUL-09                              Y
    02-JUL-09 - 25-JUL-09                              N
    26-JUL-09 - 01-JAN-10                              Y
    02-JAN-10 - 13-JAN-10                              N
    14-JAN-10 - 18-JAN-10                              Y
    19-JAN-10 - 30-APR-10                              N
    6 rows selected.
    Elapsed: 00:00:00.35

  • Determine posting to an asset between two dates

    Hello all,
    How do you calculate the postings made to an asset between two dates?  I looked at the logical database ADA, but got lost in the source code.
    For example, if these posting were made to an asset between start & end date, the total I would want would be $300.
    Post $200
    post $100
    post $200
    reserse the 2nd $200.
    Thanks
    Bruce

    Dear Friend,
    Its very easy, simply execute transaction SQV and follow the below steps
    Quick Viewer Screen appers
    Create a new quick view
    Give it a name, data source as table join, press enter.
    Press Shift+F1, put the table name ANEK and press enter
    Again press Shift+F1, put the table name as ANEP this time.
    Press F3 or back button
    Explode the Documnet Header and select List Filed and Selection Field check box for 1. Company Code 2. Main Asset Number, 3. Asset Sub Number,4. Fiscal Year, 5. Sequence Nuber, 6. Document Date or any other date on the basis of which you want to check the postings (e.g. posting date, entery date, asset valud date etc).
    Press Execute button and enter.
    A Report selection will appear, put the company code other parameters you have with you inclduing the date and execute again.
    This will give you all posting between particular date.
    Hope this solve your issue.
    Thanks!!!
    Murlidhar Khatri

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

Maybe you are looking for

  • Exception handling in jinitiator

    hallo, we are currently using jinitiator 1.3.1.9 and i have a little question concerning the exception handling in it. i don't think, that the handling differes to older version, so maybe one can help me out though he uses an "older" version. now the

  • Mail notification at value placed at approver field in Additional tab

    Hi SAP Gurus, in the business  based on the document (DIR ) we are creating there will be specific person responsible for approving the document. so we have created a characteristic values in additional tab field, having the list of names / values of

  • Constantly getting error 503 on FDM and HFM

    Hi, We are new user, using version 11.2.2.3. Every time there are major processes that required a lot of resources (e.g consolidation, multiple load, multiple processes), our FDM/HFM server server will spit out 503 error. It will lock the user and ev

  • How can I make message preview font larger?

    How can you increase font size in the message preview box?

  • Iweb slideshow problems

    I have created a slideshow with music in iphoto. When i export it to iweb and publish it to my site the video only plays for about 5sec then it stops completely. But the video works fine if i just play it on my computer. I Have called godaddy and ask