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.

Similar Messages

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

  • Date and time difference for weekdays - urgent

    Hi,
    Is there any fun.module which will caluculate the difference between two dates and time  excluding weekends?
    Thanks in advance.
    Srini.

    Hi,
    Refer to the following link:
    http://sap-img.com/abap/function-to-return-next-business-day.htm
    Hope this helps.
    Reward if helpful.
    regards,
    Sipra

  • SAP XI : Date and Time Service

    Hi All,
    Is there any runtime variable or service  in SAP XI through which I can
    map the current DATE and TIME of the system. Currently I am using XSLT mapping and
    in that XSL I am calling java code for Date and Time.
    So is there any other way through which I can Map the date in the output field
    without calling Java code in XSLT.
    Thanks
    Farooq

    hi,
    you can do it from java - if you use XSLT on java stack
    you can do it from ABAP - if you use XSLT on ABAP stack
    there are also java functions for date
    in message mapping
    so you can put two mappings (in your <b>interface mapping</b> object):
    one XSLT
    and one message mapping which will only fill the date
    to see how many mappings work have a look at my weblog:
    /people/michal.krawczyk2/blog/2005/11/01/xi-xml-node-into-a-string-with-graphical-mapping
    Regards,
    michal
    <a href="/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions"><b>XI / PI FAQ - Frequently Asked Questions</b></a>

  • How to find the date and time difference in InfoPath 2013?

    Hi All,
    My date and time format is like: 2013-12-24T10:47:38 and have three fields Start date, End date and Actual time taken.
    If start date and end date filled then actual time taken field should automatically should fill, for example 2 days 12 hours 48 min 3 sec.
    How to achieve this?

    Hi Sam,
     I believe we had discussed the same issue in the below thread. Can you please refer the below one?
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/d93e16ff-c123-4b36-b60b-60ccd34f6ca7/calculate-time-differences-in-infopath?forum=sharepointcustomizationprevious
    If it's not helping you please let us know
    Sekar - Our life is short, so help others to grow
    Whenever you see a reply and if you think is helpful, click "Vote As Helpful"! And whenever
    you see a reply being an answer to the question of the thread, click "Mark As Answer

  • How to get exact date and time difference?

    Hi,
    When i am using the below sql statement:
    SELECT (TO_DATE('7/27/2006 05:00:15 PM','MM/DD/YYYY HH:MI:SS PM') - to_Date('7/27/2006 8:30:13 AM','MM/DD/YYYY HH:MI:SS AM')) * 24 hours FROM DUAL;
    the output is:
    Hours
    8.50055555555556
    But Actually it is 8.30
    So how can i get exact days and time difference between two dates in Oracle?
    Thanks....
    Regards,
    Suman Sakinala
    Edited by: SSN on Sep 19, 2008 1:27 AM

    Or more clearly (this time I have my date_from and date_to the right way around hehe!)
    SQL> ed
    Wrote file afiedt.buf
      1  WITH t as (select TO_DATE('7/27/2006 05:00:15 PM','MM/DD/YYYY HH:MI:SS PM') as dt_to,
      2                    TO_DATE('7/27/2006 08:30:13 AM','MM/DD/YYYY HH:MI:SS AM') as dt_from FROM DUAL)
      3      ,d as (select (dt_to-dt_from)*24 as diff_hrs from t)
      4  -- end of dates
      5  SELECT TRUNC(diff_hrs) as hours
      6        ,TRUNC(((diff_hrs) - TRUNC(diff_hrs))*60) as mins
      7        ,TRUNC(((((diff_hrs) - TRUNC(diff_hrs))*60) - TRUNC(((diff_hrs) - TRUNC(diff_hrs))*60))*60) as secs
      8* FROM d
    SQL> /
         HOURS       MINS       SECS
             8         30          2
    SQL>

  • Date formats-time difference

    Hi,
    Any function module which can give the date and time difference if i input the date and time in the following format
    20090322       (date)
    20090321       (date)
    040004 (time)
    040000 (time)
    I had checked the other FM's but those are not in synch with the date format I am giving.Do anyone here know about a FM which can give the time difference even if we input the date and time in the above format.
    Format is the problem I am facing.
    Thanks,

    Hi Folks,
    I just want to avoid all the below computations and expecting to get the result irrespective of whichever the date format is,ie a function module which gives me the time difference irrespective of the date format that is fed as input.Seems it is not possible.
    data:date1(08) type C value '20090322',
         date2(08) type c value '20090322',
         time1(08) type c value '060648',
         time2(08) type c value '062403',
         date3(08) type C,
         date4(08) type c,
         time3(08) type c,
         time4(08) type c,
         temp1(08) type C,
         temp2(08) type c,
         temp3(08) type c,
         temp4(08) type c,
         temp5(08) type C,
         temp6(08) type c,
         temp7(08) type c,
         temp8(08) type c,
         temp9(08) type c,
         temp10(08) type c,
         temp11(08) type c,
         temp12(08) type c,
         gpdt type d,
         gptm type t,
         smsdt type d,
         smstm type t,
         e_tdiff type cva_time,
         v_diff type cva_time,
         e_days type i.
    temp1 = date1+0(4). "year
    temp2 = date1+4(2)."month
    temp3 = date1+6(2). "date
    temp4 = time1+0(2)."hrs
    temp5 = time1+2(2)."mins
    temp6 = time1+4(2)."secs
    temp7 = date2+0(4). "year
    temp8 = date2+4(2)."month
    temp9 = date2+6(2). "date
    temp10 = time2+0(2)."hrs
    temp11 = time2+2(2)."mins
    temp12 = time2+4(2)."secs
    concatenate: temp3  temp2  temp1 into gpdt,
                  temp9  temp8  temp7 into smsdt,
                  temp4  temp5  temp6 into gptm,
                  temp10  temp11  temp12 into smstm.
    CALL FUNCTION 'SCOV_TIME_DIFF'
      EXPORTING
        im_date1                    = gpdt
        im_date2                    = smsdt
        im_time1                    = gptm
        im_time2                    = smstm
    IMPORTING
       EX_DAYS                     = e_days
       EX_TIME                     = e_tdiff
    * EXCEPTIONS
    *   START_LARGER_THAN_END       = 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.
    write:/ e_tdiff,
            e_days.
    Thanks,

  • How Production Order finish date and time is being comptued by SAP?

    Hello Expert,
    How Production Order finish date and time is being comptued by SAP? for example, we create a Production Order via CO01, the basic start date is 29.09.2008 and time is 04:00 it gives us basic finish date is 29.09.2008 and time is 13:28.
    how does SAP compute the time 13:28 as it finished time
    Please explain me briefly.
    Thanks
    Ryan

    Hello Guys,
    When we create Production Order in R/3 the time is calculated by routing but it is extended at SetUp machine time. It is not correct?. SetUp imachines time used only for first Production Order for the same product and it is plan manually, for others Production Order we need calculate time for production without SetUp machine time being pick up to compute finish time. how could we achieve this? only those Machine time will be check.
    thanks

  • There is something wrong with the volumes buttons in my macbook pro, every time i pressed the one who raises the volume, it leads me to the screen where (i do not no what its called) the background is black with the date and time and a calculator.

    There is something wrong with the volumes buttons in my macbook pro, every time i pressed the one who raises the volume, it leads me to the screen where (i do not no what its called) the background is black with the date and time and a calculator. However, when i lower it, my safari tab goes out of the screen. What do you guys think i should do? I'm getting very nervous.

    hey HAbrakian!
    You may want to try using the information in this article to adjust the behavior of your function keys to see if that resolves the behavior:
    Mac OS X: How to change the behavior of function keys
    http://support.apple.com/kb/ht3399
    Take care, and thanks for visiting the Apple Support Communities.
    -Braden

  • How to view current  date and time on SAP screen

    Hi Everybody,
    How to view current  date and time on SAP screen .I have set time zone in T-code STZAC.now iam getting correct date n time in my tranctions but i want to check without any tractions
    Plz repay,Regards,
    Sadik.

    Hi,
    You can check the time by running a report .
    It will show the database and central instance time : Report name :rsdbtime
    Thanks and Regards
    Vijay kumar G
    Edited by: vijay kumar gopal on Mar 4, 2008 1:09 PM

  • Date and Time calculation in the Service Module

    Dear all,
    I have quite of a challenge here and i need serious guidance from your side.
    My client is in services industry and requires to calculate the date and time when the service call as to be closed. Not only it depends on the contract type the service is linked to but as well on the priority.
    The priority in Business One is unique, therefore we created a UDT (User Defined Table) to store the different 'response time' per contract/per priority. Example: a Platinum contract is always 24/7. But a gold contract priority 1 has to be closed in 240 minutes (4 workable hours) while a gold contract priority 2 has to be closed in 480 minutes (8 workable hours).
    I created 7 user defined fields on the Service Contract header that calculates the workable minutes per day. So if my coverage for Monday is from 8 AM to 4 PM, my UDF called DiffMon will show 480. For Tuesday, they start a bit later, and the coverage is 8:30 untill 16:00, therefore my UDF called DiffTue = 450.If the check box before the day in the Service Contract window is not ticked, then the UDF shows zero.
    I succeeded to calculate the expected closing time by using CASE WHEN statements as following, (all calculated in minutes):
         First, I need to check which day the Service call is created: A Monday or Thursday or... since my time coverage can change every day! I use SET DATEFIRST = 1 and compare today's date accordingly with my UDF DiffMon, DiffTue, etc.
         Then, When end of coverage time today Monday (4PM) minus the create time on the Service Call (1PM) is less then the time stored in my user defined table for that contract and that priority (i.e.480), then just add that to the create time and the create date (DateAdd(mi,...,...) ).
        When end of coverage time Monday (4PM) - Create time (1PM) + DiffTue(450) is bigger than 480, then I know I have enough time to solve my service call tomorrow Tuesday and I take the start time of Tuesday (8:30) + remaining time from yesterday (480-180 -> 180 = 3hours from 1PM to 4PM) and add that to the Create date + 1 so the end result will show Tuesday date and a time of 13:30
       Etc. untill I cover all possibilities based on which day is the service call created.
    NOW, I need to include the holiday table !!!!!!!!!!  And I can't foresee how the hell I am going to do that.
    The maximum coverage can go up to 60 hours, that means more than a working week! What happens if I have more than one bank holiday in that week period? What happens when my holiday table tells me that  date is a bank holiday but it is actually a Sunday and my contract is only running from Monday to Friday?
    Am I going straight to a big mess up?
    I will highly appreciate your comments,
    Regards,
    Frederic

    Hi,
    it is possible in query designer,
    u do the two things for getting the days between to dates
    1) in CMOD write the code for sy-datum create a customer exit variable in query as on caldate like eg zcedate
    when 'zcedate'.
    clear l_s_range.
    l_s_range-sign = 'i'.
    l_s_range-opt = 'eq'.
    l_s_range-low = sy-datum.
    append l_s_range to e_t_range.
    u write this code exit_saplrrso_001.
    it givs the sydatum
    2) then u create one more variable on zdate limit with replacement path
    then u go forto create the formula variable then it display ascreen there u select both customer exit variable and replacement path variable
    zcedate-replacementpathvariable
    it gives days i worked on this and succedded.
    like the same way fortime also u can do but here at the time of creating the customer exit varible u go for option as range here
    l_s_range-low = '20012009'
    l_s_range-high = '29012009'
    l_s_range-sign ='i'.
    l_s_range-opt = 'bt'.
    please try with the above one.
    Thanks & rEgards,
    k.sathish

  • Extract Time from date and Time and Need XLMOD Funtion to find the Difference between Two Time.

    X6 = "1/5/15 5:16 AM" & NOW ....................difference by Only Time
    not date
    X6 date and Time will be changing, Its not Constant
                Dim myDateTime As DateTime = X6
                Dim myDate As String = myDateTime.ToString("dd/MM/yy")
                Dim myTime As String = myDateTime.ToString("hh:mm tt")
                Dim myDateTime1 As DateTime = Now
                Dim myDate1 As String = myDateTime1.ToString("dd/MM/yy")
                Dim myTime1 As String = myDateTime1.ToString("hh:mm tt")
    Need to use this function to find the Difference between Two Time. due to 12:00 AM isuue
    Function XLMod(a, b)
        ' This replicates the Excel MOD function
        XLMod = a - b * Int(a / b)
    End Function
    Output Required
     dim dd  = XLMod(myTime - myTime1)
    Problem is myTime & myTime1 is String Need to convert them into Time, Later use XLMOD Funtion.

    Induhar,
    As an addendum to this, I thought I'd add this in also: If you have two valid DateTime objects you might consider using a class which I put together a few years ago
    shown on a page of my website here.
    To use it, just instantiate with two DateTime objects (order doesn't matter, it'll figure it out) and you'll then have access to the public properties. For this example, I'm just showing the .ToString method:
    Option Strict On
    Option Explicit On
    Option Infer Off
    Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) _
    Handles MyBase.Load
    Dim date1 As DateTime = Now
    Dim date2 As DateTime = #1/1/1970 2:35:00 PM#
    Dim howOld As New Age(date1, date2)
    MessageBox.Show(howOld.ToString, "Age")
    Stop
    End Sub
    End Class
    I hope that helps, if not now then maybe at some point in the future. :)
    Still lost in code, just at a little higher level.
      Thanx frank, can use this in Future....

  • Automatic changing of activity start date and time of planned orders in SAP

    Hello experts,
    I have a requirement that in the transaction /SAPAPO/SEQ1 for the list of planned orders what ever we get in the sap we have to swap the activity start date and time for two planned orders which we select automatically. For this I have found the BADI "/SAPAPO/SEQ_VISUAL01".
    Now i am able to identify the two selected planned orders inside the BADI method SEQGRID_TOOLBAR_OKCODE_HANDLE.
    Now my requirement is i have to swap the start date and time for these two planned orders automatically i.e. through BAPI or any FM.
    Any idea of any BAPI or FM to change the details of the planned order.
    Thanks,
    Sanath.

    Hi Sanath,
    Please check this BAPI BAPI_MOSRVAPS_SAVEMULTI3.  This Bapi has the provision of chaning Planned Order & Production Order Data. Also, you can explore more info on available bapis in the T-code 'BAPI'.
    Thank you,
    Santosh KB.

  • Fetching SAP Date and Time format

    I am using  "RFC_READ_TABLE"  function module  to fetch SAP table contents using JCO APIs. I need to know the date and time format to parse the values of date and time fields into respective java data types. (I am receiving these values in the form of string using above RFC)
    How can I get date and time format information from SAP server?
    Regards
    Amol

    Hi,
    Through T-Code SU01 in general setting tab   u can do the general setting for  date time, number format
    Type tcode SPRO and Got to general settings -> Define Countries then  restart the system.

  • Difference between a starting date and time and ending date and time

    Hi All,
    I need to bring out the difference between a starting data and time and ending date and time. Difference should be in time I mean it should be in hours or minus or seconds.
    I am sure there must be a Function module for this, Has anyone of you been in search of this kind of FM, Kindly suggest me. It is urgent.
    Thanks
    Mahen

    Hi,
    Check this out.
    data : date1 type dats ,   " System data type for Date (sy-datum)
           date2 type dats,
           time1 type tims,      " System data type for time (sy-timlo)
           time2 type tims,
           days  type i,
           scd   type i,
           t_mt  type i.
    days = date1 - date2. " Diference in days.
    Scd  = time1 - time2. " diference in seconds.
    t_mt =  ( days * 24 * 60 ) + ( scd / 60 ).
    total diference in minute
    <b>Reward Points & Mark Helpful Answers</b>

Maybe you are looking for