Time difference calculation

Dear All ,
Is there in fuction module which gives me difference in time  in terms of HH:MM:SS taking date also into consideration .

HI,
use this.
data : date1 type sy-datum, 
                  date2 type sy-datum,   
                  time1 type sy-uzeit,  
                  time2 type sy-uzeit,  
                  v_datediff type p,     
                  v_timediff type p.   
date1 = '20060101'.  
date2 = sy-datum.   
  time1 = '010101'.    
  time2 = sy-uzeit.
CALL FUNCTION 'SD_DATETIME_DIFFERENCE' 
EXPORTING   
DATE1                  = DATE1  
TIME1                  = TIME1 
DATE2                  = DATE2  
TIME2                  = TIME2
IMPORTING 
DATEDIFF               = v_DATEDIFF  
TIMEDIFF               = v_TIMEDIFF
*EARLIEST              = EARLIEST
EXCEPTIONS 
INVALID_DATETIME      = 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.
rgds
Anver
<b><i>pls mark all hlpful answers</i></b>

Similar Messages

  • Time Difference Calculation Using Shared Variables

    I have a subreport that is passing times(HH:MM:SS AM) through shared TIMEVAR variables to a main report.  I am trying to use these shared variables to calculate a time difference between the shared variable and one in the main report.  The shared variable passes without problems and I end up with a numeric value when trying to subract the two time fields.  What am I doing wrong?

    Here is an example for converting seconds to hh:mm:ss  ( Hopefully the message will not lose the (Parens))
    WhilePrintingRecords;
    StringVar Hours1;
    StringVar Minutes1;
    StringVar Seconds1;
    NumberVar MY_SECONDS_1:=0;
    MY_SECONDS_1:= ;
    If MY_SECONDS_1 < 0 Then
      "Cannot have a time less than zero"
    Else
      (Hours1:=ToText(Truncate(MY_SECONDS_1/3600),0);
      Minutes1:=ToText(Truncate(Remainder(MY_SECONDS_1,3600)/60),0);
      Seconds1:=ToText(Remainder(Remainder(MY_SECONDS_1,3600),60),0));
    Display the time formated.
      (if length(Hours1) < 2 then '0') + Hours1 + ":" +
      ["0",""][length(Minutes1)] + Minutes1 + ":" +
      ["0",""][length(Seconds1)] + Seconds1;

  • SAP BI Date and Time Difference calculations in DSO Transformation

    Hello Guys,
    Could you please tell me how to calculate the date and Time difference between 2 fields.
    I have 2 date fields :
    Arrival Date : 6/16/2007
    Departure date : 6/19/2007
    Also i have 2 time fields for the above
    Arrival Time : 13:00:00
    Departure Time : 11:50:00
    I want to display all the four fields and 2 fields for the difference in Date and Time.
    Is it better to calcuate the differences in DSO Transformation or can you do it in the report itself.Could you please let me know the solution.
    Thanks,
    BI Consultant

    Hello Consulant BI,
    Computing the difference of two dates is easy (assuming you really just want the number of days). You can simply subtract the two dates using ABAP:
    data: w_arrival_date type sy-datum,
            w_dep_date type sy-datum,
            w_diff type i.
    w_arrival_date = <your arrival date field here>.
    w_arrival_date = <your departure field here>.
    w_diff  = w_arrival_date - w_dep_date.
    Getting the time difference isn't really much logical. I think what you want instead is to compute the totals days (and extra hours) right? If this is the case, then you can convert the date+time for both the arrival and departure  into a timestamp variable first and then t the get difference.
    Hope this helps.

  • Date and time diffrence calculations

    Dear Experts,
    I have a doubt regarding the date and time diffrence calculation please help me out.
    This is regarding the report called u201CVehicle tracking systemu201D. The purpose of this report is to give the user information like how many vehicles have come in and how much time each vehicle has parked in the filling in the refinery and also the average time taken for a customer.
    For this we have created 4 info objects called
    1)     Park In Time
    2)     Park In Date
    3)     Gate Out Time
    4)     Gate Out Date
    We have created a routine which calculate the difference in Vehicle Park In Date & Time to Gate Out Time and Date
    The Time difference is number format.
    Example: For Vehicle1
    Park in Date and Park in Time are         27.11.2008 and 17:43:35
    Gate out Date and Gate out Time are     29.11.2008 and 09:36:16            
    Here routine will calculate the difference in the above date and time and the output is like this     1,155.138,000 (i.e. 1day, 15 hours 51 mins and 38 seconds) that means the vehicle has parked for 1 day and 15 hours etc.
    But we require the output like    1 day, 15:51:38
    Please give us the solution how to go about it.
    Thanks in advance,
    venkat

    Hi,
    I think in regard to your problem, the solution will be to make the variables in the query runtime by the replacement path variable.
    Please find the below link, its very much self explanatory and in regard to your problem.
    Hope it helps!
    [http://sd-solutions.com/documents/SDS_BW_Replacement%20Path%20Variables.html]
    Regards,
    Neha.

  • Stopping a while loop using the time difference of two tick counts

    Hi Guys,
    I'm currently writing a code which test how long does it take for a formula node to perform its operation. The program uses a while loop to perform the calculation, and the program stops after calculating when tick count has reached 10 seconds. The program then displays the number of iterations it does in 10 seconds. 
    So initially I created 2 frames of sequence structure. In my first frame I have my initial tick count, and in my second frame I have my final tick count and the while loop. I used the subtract function and divide the output by 1000 to get the time difference. Then using the comparison function, I set if output > 10 then the program should stop, to do this I linked the output of the comparison function to the stop button inside the while loop. 
    However, when I tried to run the code, the program just didn't run. Hence I created a similar program which puts the last tick count in new frame sequence. When I ran this code, the program never stopped. 
    Do you guys have any idea what went wrong with my codes.
    Thank you!
    Erry
    Solved!
    Go to Solution.
    Attachments:
    1. Tick Count.vi ‏27 KB
    tickcoun2.vi ‏27 KB

    Dataflow!
    In both VI's the stop terminal of the while loop is controlled by a boolean whose source is ouside of the while loop.  So that loop will either run once, or run forever, depending on the value of the boolean that is calculated before the loop starts and shows up at the tunnel going into the loop.
    I would recommend looking at the online LabVIEW tutorials
    LabVIEW Introduction Course - Three Hours
    LabVIEW Introduction Course - Six Hours

  • Standard function for returninf time difference in days and hours.

    Hello all,
                Can somebody tell me whether there exists some standard function module which can calculate the time difference and returns the calculated time in the form of days and hours ?
    e.g. the time difference between the date 1.12.2007 from 7.00 pm to the date 1.1.2008 till 9.00 pm is
    30 days  and 2 hours or 30 : 2.
    answer as soon as possible.
    Thanks and regards,
    me

    Thanks a lot ya..
    thats an absolutely correct solution to my problem.  )

  • Time Stamp Calculation

    Hi,
    I am using Oracle Database version 11.2.1 and would like to calculate the time difference in minutes between start_date, start_time and end_date, end_time. The date is stored in a seperate column to the time. Also the time is stored as a number.
    Please see the test scripts below:
    create table test
    (start_date date,
    start_time number,
    end_date date,
    end_time number)
    insert into test values('20-JAN-2012', 103413, '01-FEB-2012', 110917);
    insert into test values('01-MAR-2012', 091734, '01-MAR-2012', 103555);
    insert into test values('19-APR-2012', 103413, '20-APR-2012', 125012);
    insert into test values('13-JUL-2012', 123432, '13-JUL-2012', 123450);
    insert into test values('01-MAY-2013', 164522, '06-MAY-2013', 110917);
    insert into test values('10-MAY-2013', 085011, '13-MAY-2013', 135635);
    Please note that the following exceptions need to be taken into account in the calculation
    1. Exclude weekends (Sat & Sun)
    2. Only calculate working hours from 08:45am to 17:15pm
    Can anyone help?
    Thanks

    sliderrules wrote:
    Hi,
    The fields are stored this way in the system and are extracted as two seperate columns. Can the data and time be combined into one date field?Hi,
    I agree with John that this is a really bad design. You actually don't need start_time and end_time as you can have all the information start_date and end_date.
    i.e.:
    update test
       set start_date = TO_DATE(TO_CHAR(start_date,'YYYYMMDD')||TO_CHAR(start_time,'fm000000'), 'YYYYMMDDHH24MISS')
         , end_date   = TO_DATE(TO_CHAR(end_date  ,'YYYYMMDD')||TO_CHAR(end_time  ,'fm000000'), 'YYYYMMDDHH24MISS');
    select start_date, end_date
    from test;
    START_DATE            END_DATE            
    20/01/2012 10:34:13   01/02/2012 11:09:17 
    01/03/2012 09:17:34   01/03/2012 10:35:55 
    19/04/2012 10:34:13   20/04/2012 12:50:12 
    13/07/2012 12:34:32   13/07/2012 12:34:50 
    01/05/2013 16:45:22   06/05/2013 11:09:17 
    10/05/2013 08:50:11   13/05/2013 13:56:35  And for calculate your working hours you can have a look at this: {message:id=10655484}
    Regards.
    Al
    Edited by: Alberto Faenza on May 21, 2013 2:11 PM
    Added link for hours calculation

  • Time of calculation before aggregation is obsolete

    Hi Gurus,
    I have this message when i try to ejecute my query, can anyone help me to resolve this problem, i have the SAP 7.0 EHP 1, and i just have the upgrade from SAP 3.5.
    I have a lot of CKF's in my queries and all of those use BEFORE AGGREGATION option, when i put in the propietries of my CKF the option after aggregation and then i check my query i have a message "time of calculation before aggregation is obsolete", and then when i put the option before aggregation in my CKF i have the message "CALLATE = 0 is not allowed".
    I hope that someone have the same issue and can help me with this.
    note: i'm using the BEX 3.5 and the BW 7.01 because the client wants that.
    tnks
    regards
    Odiseo
    Edited by: Odiseo BW on Oct 18, 2010 7:46 PM

    hmmm... how about checking the differences between 3.X & 7.X???
    before aggregation is no longer possible in 7.X, hence the error messages

  • Arbitrary time period calculation.

    How to do time series calculations for custom time series which are not sequential.
    We have time period called diet which is not sequential like calender date Example given below :-
    May 2012 Diet starts from 24/04/2012 to 16/06/2012 And May 2011 Diet starts from 01/02/2011 to 31/05/2011 diff
    100 50 50
    we need to compare May 2012 diet to May 2011 diet and create a difference column and also need to calculate variance on this. Also need to add other dimension like geography and status
    For this i tried to use Ago function but it wont allow us to calculate as they are not sequential
    Let me know if there is any solution.
    Thanks
    prabhu

    Any one on this ....

  • How to calculate the % of time difference between different state

    Hi there,
    The below query returns the follwoign outptut. I need to calculate the % of time period that a specific state ( state ex: open or closed or all report )exists.
    I have to find the time difference between the 2 states . How could I do that ?
    The first row shows null for the previous state . How could get actual previous state for the first row?
      SELECT si.station_name,
                    vppstation.avi_control_state_code.STATE_SHORT_NAME,
                    ash.state_id ,
                    lag(ash.state_id) over (order by ash.STATE_EFF_DATE desc) previous_state,
                    TO_NUMBER(TO_CHAR(ash.state_eff_date, 'SSSSS')) "periods in sec",
                    TO_CHAR(ash.state_eff_date, 'dd-mon-yyyy hh24:mi:ss am') "Date"
               from vppstation.avi_state_history ash
    left outer join vppstation.avi_control_state_code
                 on ash.state_id = vppstation.avi_control_state_code.state_id
    LEFT OUTER JOIN vpproadside.stations_installed si  
                 ON ash.station_id = si.station_id               
              where ash.state_eff_date >= to_date('28/02/2010', 'dd/mm/yyyy')
                and ash.state_eff_date <= to_date('03/03/2010', 'dd/mm/yyyy') ;
           group by si.station_name
                         ash.state_id
           order by ash.state_eff_date asc ;
    STATION_NAME                   STATE_SHORT_NAME STATE_ID               PREVIOUS_STATE         periods in sec         Date                   
    IRDNCST02                      Open             1                    NULL                  85166                  01-mar-2010 23:39:26 pm
    IRDNCST02                      All Report       3                      1                      85159                  01-mar-2010 23:39:19 pm
    IRDNCMT01                      Closed           2                      3                      81376                  01-mar-2010 22:36:16 pm
    IRDNCST02                      Open             1                      2                      78723                  01-mar-2010 21:52:03 pm
    IRDNCST02                      All Report       3                      1                      76023                  01-mar-2010 21:07:03 pm
    IRDNCMT01                      Open             1                      3                      55922                  01-mar-2010 15:32:02 pm
    IRDNCMT01                      Closed           2                      1                      54931                  01-mar-2010 15:15:31 pm
    IRDNCHA01                      Closed           2                      2                      41291                  01-mar-2010 11:28:11 am
    IRDNCAS01                      Open             1                      2                      38847                  01-mar-2010 10:47:27 am
    IRDNCAS01                      All Report       3                      1                      37947                  01-mar-2010 10:32:27 am
    IRDNCST02                      Open             1                      3                      35332                  01-mar-2010 09:48:52 am
    IRDNCST02                      All Report       3                      1                      32632                  01-mar-2010 09:03:52 am
    IRDNCST02                      Open             1                      3                      31502                  01-mar-2010 08:45:02 am
    IRDNCST02                      All Report       3                      1                      28802                  01-mar-2010 08:00:02 am
    IRDNCHI01                      Open             1                      3                      25368                  01-mar-2010 07:02:48 am
    IRDNCHI02                      Open             1                      1                      23939                  01-mar-2010 06:38:59 am
    IRDNCMT01                      Open             1                      1                      20696                  01-mar-2010 05:44:56 am
    IRDNCCH02                      Open             1                      1                      13452                  01-mar-2010 03:44:12 am
    Edited by: Indhu Ram on Mar 11, 2010 1:34 PM
    Edited by: Indhu Ram on Mar 11, 2010 2:20 PM

    If you look at the table which is output of the given query , there is column called "STATE_ID" It shows the current state ie open or closed or all report.
    The column 'PREVIOUS_STATE' shows the state before the current state. .In the table in 2nd row in previous_state column there is state_id = 1 (open)which is the state before 'all report state'

  • How to measure time difference between zero crossing of a sine wave and rise time of a pulse on a same graph?

    I have a 50Hz sine wave and a pulse signal on a same graph. The phase difference between two is between 0-90 degrees.
    Now I need to calculate the time difference between (when the sine wave crosses zero volts) and (when the pulse rises). The frequency will stay approximately same for both signals.
    The application is for a three phase generator. In simple words, when the time difference between the zero-crossing of sine wave and the pulse rises increases, that means that the load on the generator has increases.
    I am a beginner user of LabView (version 9, 2009), maybe it is a very simple problem but I've been pulling my hair out for the last few days and coudln't figure anything out. Any help would be greatly appreciated. I am using DAQ USB-6008 to measure these voltages and pulse from the generator and a sensor
    I have attached a jpg (a graph that i just made with excel to explain). The time 't' is what I am trying to measure
    Cheers
    Awais 
    Message Edited by awais.h on 03-30-2010 11:20 PM
    Message Edited by awais.h on 03-30-2010 11:21 PM
    Solved!
    Go to Solution.

    Hi
    Thanks for the code but I'm afraid it won't work. Like you said the probability of choosing a value that is on both graphs may not happen. This is something that I would like the code to do automatically.
    But I did use the previous code posted and made some modifications to it and it seems to work perfectly. Now the next thing is to be able to get just that one value that tells you the first time difference.
    Here is what I get using that code.
    As you can see from the t Values. I only need the one that is highlighted. If there is a way to filter out the rest it would be great.
    I was thinking of a while loop and as soon as the value is higher than 3E-5 it would store the number and stop the loop, but I'm not too familiar with arrays in labview.
    Here is the the code modified.
    As you can see, it wasn't that big of a modification and it still is your code.
    I will keep trying.
    Thanks for the help
    Attachments:
    FinalShockSpeed.vi ‏55 KB

  • Lost connection detection time difference

    Having a problem understanding why a broken JDBC connection is detected under Windows much quicker than it is under Linux.
    I have an process that opens a connection to MSSQL using JDBC, a Stored Procedure is then executed and the result set
    processed, this execute step is repeated every 60 seconds or so. If any exception is thrown then resources are closed, sleep
    for 60 seconds, the connection is reopened (if fails then sleeps and repeats), once reopened the process continues. There is logging throughout
    the above steps.
    On Windows Vista 64bit Sun Java platform the process runs fine, if I deliberately break the connection (stop MSSQL service), the process
    logs a problems within 60 seconds and starts handling the error, when the MSSQL comes back then within 60 seonds the connection is remade
    and the process continues as expected.
    Under Ubuntu 10 64bit both Sun and OpenJDK the process runs fine, until the connectionis broken, as it takes about 17 minutes for the exception to be thrown
    for the broken connection (stopped MSSQL) to be detected, as opposed to under Windows taking seconds. Once detected then the process works as expected, retrying
    and reconnecting as it should.
    The libs and code used are the same the only difference between the windows and linux versions are the logging path parameter, have tried with different versions of Java
    and with different MSSQL JDBC drivers.
    What could be the reason for the time difference in the lost connection detection between Windows and Linux? Any help tips would be most welcome.
    Thanks.

    The connection is only made once and used throughout, it is only closed if there is a problem. This runs absolutely fine with logging for weeks, the execute and processing take millisecondsIt is pointless to keep the connection in that situation. Create it every time.
    Doing that might even fix your problem. But regardless you should still not keep it.
    Have jujst checked the timings and if the db connection is broken the on Linux (Ubuntu) the exception generated by step 4. takes up to 15 minutes 35 seconds to move on to step 7. on Windows though it is instant, there is a log message output prior to the execute statement this outputs then the exeception logged.You have an existing connection.
    Then you attempt a request which I am guess takes 17 minutes to timeout. (That happens because you are testing by stopping the server.)
    That is the problem.
    First verify the connection url. It might have timeout values in it.
    If not then the next most likely cause is that someone changed the OS (not java) TCP timeout values. Bad idea if they did. And the only way to fix is to change them back to something reasonable. You can code around this by using two threads. One that sets a timer and the other that runs the request. If the timer fires then attempt to cancel the request (see the jdbc api.)

  • Warning "Time of Calculation 'Before Aggregation' is obsolete" in BI 7.0

    Hi Friends,
    We have recently upgraded our BW system from BW 3.1 to BI 7.0. While executing one of the query in BI 7.0 i am getting the Warning Message "Time of Calculation 'Before Aggregation' is obsolete". I can run the query by ignoring the message and get the results. But I am not getting the correct result for some of the calculated key figures which has setting for Time of calculation as "Before Aggregation".
    After doing some research i found that before aggregation is not allowed in BI 7.0. We are using queries created in 3.x environment. There is some work around which talks about creating new calculated key figure with after aggregation setting and all. But in my case it not feasible as there are so many queries based on those calculated key figures.
    Does any one had the similar situation? Is there any other way to correct this problem?
    I would appreciate your help in this regards.
    Thanks,
    Manmit

    Hi
    Try SAP notes 935903.
    Symptom
    Calculated Key Figures "Existance Indicator" with aggregation behaviour "Before Aggregation" will get now with NW 2004s warning popup "Time of calculation 'Before Aggregation' is obsolete" during execution.
    this may be helpful.
    Also Check the below thread
    /message/2986338#2986338 [original link is broken]
    Regards
    Shilpa
    Edited by: Shilpa Vinayak on Oct 10, 2008 4:23 AM

  • How to find out time difference between 2 consecutive characters coming in

    Hi
    Data is coming on serial port and m taking this data in a input stream.I need to know the time difdference between consecutive characters.Any ideas?

    What do you mean? If you meassure the time between two characters, you want to calculate how accurate it is? First you would need to find out how accurate the System.currentTimeMillis is on the platform you run on. That may be easy
    long start = System.currentTimeMillis();
    long end;
    while ((end = System.currentTimeMills()) == start);
    long delta = end - start;But sometimes (on win98) it reports 50, other times 60. So its not quite accurate. But you could redo that test a couple of times and take the avg or the max.
    Then if you get a time difference of 0ms between two characters, you know it will be somewhere 0 and 60ms. If you get 60ms between two characters, you know it will be somewhere between 0 and 120 ms. It's +/- delta seconds accurate.
    Would this be a way to calculate the percentage accuracy: 100.0-100.0*delta/(time+delta)
    Still better to meassure the time over more than just 2 characters unless it is a very slow stream.

  • Execution time difference between SELECT & UPDATE statement in JDBC Sender.

    Hi Experts,
    In my scenario, I have used the JDBC Sender Adapter with the SELECT and UPDATE statement.
    Now the problem is in between the execution of Select and update statement, few more entries are coming in the same DB Table.
    So result of this is updation take place for those entries which are not even picked up by the select statement.
    Can we avoid this execution time difference between the SELECT & UPDATE statemet on JDBC Sender side???
    Thanks & Regards
    Jagesh

    Hi
    Use serializable option in additional parameters, now all new entries would also be updated.

Maybe you are looking for

  • I have a iphone 3gs and its not activating. i have tried it on both my phone and itunes and neither are working. Any suggestions

    I have tried to acrivate my phone both on itunes and on my phone. Im not surwe what to do anymore? the message it says to me on my phone is "Your iphone could not be activated because the activation server is temporarily unavailable. Try connecting y

  • AP Vendor Intrest line item display

    Hi can some one please help me how to find Vendor Interest Calculation line item wise. Am using t.code f.44 but it shows whole vendor details. i just want to see vendor intrest balance Rao

  • Backing up Data in Apex

    Hello, Please does anyone knows how I could back up vital data in my application. How can I set up back up process whenever a user wants to close/log out from the application. Is it possible in Apex Thanks

  • Serious leak in Manager

    I'm encountering what seems like a serious resource leak in Manager. If I call createPlayer() with a file that JMF can't open it instantiates a com.sun.media.content.unknown.Handler (line 1435 of Manager.java) and then calls setSource on the handler,

  • CUPS localhost:631/admin gives 404 not found

    This is a bit of a story and also a pretty tough nut. A friend has a MacBook that lost its ability to print on the university campus. Because of the printer setup here, it is necessary to use CUPS to connect to a printer. She visited tech support at