SUBTRACT TIME FROM DATE & TIME

Hi.
I need FM which will SUBTRACT TIME from DATE & TIME.
Example:
Date = 05.05.2007
Time = 05:00:00
Time_subtract = 48:00:00
Return of FM:
Date = 03.05.2007
Time = 05:00:00
Do you know any FM?
Thanks!

Hi, Check these function mod's
SD_DATETIME_DIFFERENCE
HRCM_TIME_PERIOD_CALCULATE
HR_ECM_GET_PERIOD_BETW_DATES
After you execute them in SE37 give the required input and you will get a correct output.
<b>REWARD IF USEFUL</b>
thanks n regards
Dinesh

Similar Messages

  • Subtract years from date

    Hi all
    Can someone please tell me how to subtract a number of years from a date. Had a look through the forums with little success.
    Thanks

    Thanks for the response, I forgot about this post as I found a solution:
         public String SubtractYearsFromDate(int years)
              SimpleDateFormat date = new SimpleDateFormat ("dd-MMM-yyyy");
              Calendar cal = Calendar.getInstance();
              DateFormat df = DateFormat.getDateInstance();
              cal.set((cal.get(cal.YEAR) - years), cal.get(cal.MONTH), cal.get(cal.DAY_OF_MONTH) );
              String dateString = date.format(cal.getTime());
              return dateString;
    Bit convoluted though, so will give the roll() method a go. Thanks again.

  • Subtracting  number   from date

    Hi
    i face following error ,could you help me on this
    TRANS_DATE ----- DATE type
    NETWORK_DELAY- NUMBER type
    Command> select TRANS_DATE-NETWORK_DELAY from ACCOUNT_JOIN;
    2963: Inconsistent datatypes: (DATE,NUMBER) are not compatible in expression (BULK_SUBSCRIBER_JOIN.TRANS_DATE - ACCOUNT_JOIN.NETWORK_DELAY)

    dear tt0008,
    Unfortunately, TimesTen doesn't understand operations with different types. In your case it is Date and Number. You need explicitly execute type cast.
    For your task, you can use this expression:
    [oracle@tt1 info]$ ttisql "DSN=dbxla;UID=oratt;PWD=oracle"
    Copyright (c) 1996-2010, Oracle.  All rights reserved.
    Type ? or "help" for help, type "exit" to quit ttIsql.
    connect "DSN=dbxla;UID=oratt;PWD=oracle";
    Connection successful: DSN=dbxla;UID=oratt;DataStore=/u01/app/oracle/datastore/dbxla;DatabaseCharacterSet=WE8MSWIN1252;ConnectionCharacterSet=US7ASCII;DRIVER=/u01/app/oracle/product/11.2.1/TimesTen/tt1/lib/libtten.so;PermSize=32;TempSize=50;TypeMode=0;PLSQL=0;CacheGridEnable=0;
    (Default setting AutoCommit=1)
    Command> create table t (num number, date_t date);
    Command> desc t;
    Table ORATT.T:
      Columns:
        NUM                             NUMBER
        DATE_T                          DATE
    1 table found.
    (primary key columns are indicated with *)
    Command> insert into t values (1, sysdate);
    1 row inserted.
    Command> select * from t;
    < 1, 2011-07-15 10:07:02 >
    1 row found.
    Command> select to_date(to_char(to_number(to_char(date_t,'YYYYMMDD')) + num)||' '||to_char(date_t,'HH24:MI:SS'), 'YYYYMMDD HH24:MI:SS' ) from t;
    < 2011-07-16 10:07:02 >
    1 row found.
    Command>

  • SUBTRACT TIME TO DATE & TIME

    Hi.
    I need SUBTRACT TIME TO DATE & Time.
    Example:
    Date = 08.05.2007
    Time = 01:00:00
    Time_subtract = 2:00:00
    Return of FM:
    Date = 07.05.2007
    Time = 23:00:00
    Do you know any FM?
    Thanks!

    Since the max time difference can be 24 hrs you can reduce that much amount of time from the initial date and then add the difference from the initial date.
    Example : if time difference is to be calculated is 05:00:00 , since this is less than 24 , just add 24 -5 hrs = 19 hrs to the date ( subtract 1 from initial date ) using CONV_UTIL_ADD_DATE_AND_TIME.
    If time to be added is greater than 24 hrs then subtract ( TIME/24 ) from original date and add the difference to date.
    Example : 
    Date = 08.05.2007
    Time = 01:00:00
    Time_subtract = 52:00:00
    Subtract figure = 52/24 = 3 , 52 - 48 = 4.
    Return of FM:
    New date :
    Date = 05.05.2007
    Time = 01:00:00
    Now add 4 to above date using FM to get result.

  • Subtract minutes from system time

    Hi Experts,
    I want to subtract 5 min from the system time.
    Is there any function module.
    Regards,
    Chandu

    Hi Chandu,
    Use the below statment to subtract 5 minutes:
    data: v_time type sy-uzeit.
    v_time = sy-uzeit.
    v_time  = v_time - 300.
    This might solve your problem.
    Thanks,
    Chidanand

  • How to subtract Time from Sysdate

    Hello,
    I want to subtract time from sysdate and get the sysdate with time.
    Example : = (Sysdate with time)03-mar-2002 16:40:55 - 8 (hours). The result should be like :03-mar-2002 08:40:55
    How to write a query for this?.
    Please let me know as soon as possible.
    Thanks,
    Ravi.

    Hi Ravi...
    SYSDATE includes time, TRUNC(SYSDATE) does not include time.
    If you subtract these two, you'll get a positive number of 1.00 or less which is the fraction of a day. For instance high noon would have a fraction of 0.50000. 12:01 p.m. would be 0.50000 + (1/(24*60)), or 0.50069444....
    If you want to set the clock back, by calculating a "date" that is 8 hours less than the SYSDATE, then SYSDATE - (8/24) will do that. This will work even if SYSDATE was something like 2 a.m., because it will then set it to 6 p.m. of the day before the day in SYSDATE.
    If you want to set a "date" to a specific time on the day of SYSDATE, then calculate the fraction for that time and add it to the TRUNC(SYSDATE). High noon would be TRUNC(SYSDATE) + 0.5.
    SELECT TO_CHAR(TRUNC(SYSDATE)+0.5,'DD-MON-YY HH:MI:SS am') AS NOON FROM DUAL;Hope this helps...
    Larry Johnson

  • Subtract Time  from Time

    Dear Sir,
    I want to subtract Time from time, Please help me
    SELECT A.EMP_CODE,
    TO_DATE(A.INTIME,'DD/MM/RR')IN_DATE
    ,MIN(TO_CHAR(A.INTIME,'HH24:MI')) IN_TIME
    ,MAX(TO_CHAR(A.OUTTIME,'HH24:MI')) OUT_TIME
    ,TRUNC(SUM(A.TDAYS)*24)||':'||TRUNC((SUM(A.TDAYS)*24-TRUNC(SUM(A.TDAYS)*24))*60) TOTAL_TIME
    FROM HCM.EINOUT A, HCM.PERSONNEL B
         WHERE A.EMP_CODE = B.EMP_CODE AND
         TO_DATE(A.INTIME,'DD/MM/RR')BETWEEN
         TO_DATE('01/08/12','DD/MM/RR') AND TO_DATE('15/08/12','DD/MM/RR')
         AND B.DEPT_CODE = 16 and a.emp_Code = '09833'
         GROUP BY A.EMP_CODE, TO_DATE(A.INTIME,'DD/MM/RR')--, a.tdays
         ORDER BY 1, 2 ASC;
    I want to subtract 20:00 from (out_time) column from every record
    If I subtract it from first record then result in over_time column will be 2:46
    (out_time - 20:00)
    --------------Out put........................
    code date in_time out_time total_time over_time
    09833     02-AUG-12     09:18     22:46     13:28
    09833     03-AUG-12     09:16     21:50     12:34
    09833     04-AUG-12     09:28     21:41     12:13
    thanks

    this will help
    --And if difference can be > 24 hours:
    WITH t AS
         (SELECT TO_DATE ('26-aug-2011 10:10:10',
                          'dd-mon-yyyy hh24:mi:ss'
                         ) start_date_time,
                 TO_DATE ('26-aug-2011 10:12:10',
                          'dd-mon-yyyy hh24:mi:ss'
                         ) end_date_time
            FROM DUAL)
    SELECT    TRUNC (end_date_time - start_date_time)
           || ' days '
           || TO_CHAR (TRUNC (SYSDATE) + (end_date_time - start_date_time),
                       'hh24:mi:ss'
                      ) time_diff
      FROM t
    --Or interval based solution for < 24 hour diff:
    WITH t AS
         (SELECT TO_DATE ('26-aug-2011 10:10:10',
                          'dd-mon-yyyy hh24:mi:ss'
                         ) start_date_time,
                 TO_DATE ('26-aug-2011 10:12:10',
                          'dd-mon-yyyy hh24:mi:ss'
                         ) end_date_time
            FROM DUAL)
    SELECT REGEXP_SUBSTR (NUMTODSINTERVAL (end_date_time - start_date_time, 'day'),
                          '\d\d:\d\d:\d\d'
                         ) time_diff
      FROM t
    --interval based solution for >= 24 hour diff:
    WITH t AS
         (SELECT TO_DATE ('26-aug-2011 10:10:10',
                          'dd-mon-yyyy hh24:mi:ss'
                         ) start_date_time,
                 TO_DATE ('26-aug-2011 10:12:10',
                          'dd-mon-yyyy hh24:mi:ss'
                         ) end_date_time
            FROM DUAL)
    SELECT REGEXP_REPLACE (NUMTODSINTERVAL (end_date_time - start_date_time,
                                            'day'),
                           '^.0*(\d+) (.{8}).+$',
                           '\1 days \2'
                          ) time_diff
      FROM t
    --another method
    SELECT    TO_CHAR (TRUNC (nb_sec / 3600), '00')
           || ':'
           || TO_CHAR (nb_min - TRUNC (nb_sec / 3600) * 60, '00')
           || ':'
           || TO_CHAR (MOD (nb_sec, 60), '00')
      FROM (SELECT (end_date_time - start_date_time) * 24 * 3600 nb_sec,
                   (end_date_time - start_date_time) * 24 * 60 nb_min
              FROM ps_tb_ln_pdc_status_log)
    --another method
    SELECT SYSDATE + 3.45 / 24 AS "End Date", SYSDATE AS "Start Date",
           CAST (SYSDATE + 3.45 / 24 AS TIMESTAMP) - SYSDATE AS "Duration"
      FROM DUAL;Regards,
    friend.

  • Extracting time from date and adding it to another date.

    Dear All,
    The values of two fields in my table are as follows:
    n_date n_time
    12/7/2007 1/1/1970 5:50:23 PM
    Both of these fields are of date data type.
    How can i add the time from n_time to n_date so that n_date will reflect a date with time added?
    The problem is that i want to sort on n_date and i am not getting result when two dates are having same values for n_date but different for n_time.
    How can i create a new expression for sorting these values?
    Thanks in advance.
    Regards,
    Sameer

    Hi,
    Check this.
    with data as
    ( select to_date('12/7/2007','dd/mm/yyyy') as ndate, to_date('1/1/1970 5:50:23','dd/mm/yyyy hh24:mi:ss') ntime from dual)
    select ndate + (ntime - trunc(ntime)) from data
    Regards
    RK

  • How to get a time part from Date datatype

    Hi,
    I would like to know how to extract the timestamp alone from DATE datatype? If my input is '27-SEP-2011 23:59:00' I need the output as 23:59:00. I am surprised to see that there are no in-built functions for this or may be I am wrong. Basically I need to remove the date part from DATE data type and get the time.Please assist.
    -Thanks
    Edited by: user9546145 on Sep 27, 2011 2:24 PM
    Edited by: user9546145 on Sep 27, 2011 2:25 PM

    Hi,
    user9546145 wrote:
    Hi,
    I would like to know how to extract the timestamp alone from DATE datatype? Be careful! In Oracle, TIMESTAMP means a datatype, similar to but distinct from DATE. You'll avoid confusion if you don't use the word "timestamp" to mean anything else.
    There is a built-in function, TO_CHAR:
    TO_CHAR (dt_col, 'HH24:MI:SS')Depending on how you plan to use the time, TRUNC is another handy built-in function:
    dt_col - TRUNC (dt_col)is a NUMBER (not less than 0, but less than 1) which is suitable for many tasks, such as finding the average time.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables, and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using.

  • Deriving Time Characteristics from Date fields in ODS View

    Hi,
    I am creating ODS Views using HANA calculation views.
    is there any direct approach to derive time characteristics like cal week, cal quarter, cal month, calmonth 2, fiscal year, cal year etc from date fields?
    work around:
    Deriving them in HANA view in calculated columns and mapping them to IO created with respective time characteristics as reference.
    is there any standard and easy to use approach for this??
    Thanks in advance.

    Hi Ravi,
    Insteod deriving them in the ODS view you can derive them in tha Calculation View in SAP HANA itself using Time Dimention concept.
    Regards
    Jagan

  • How to subtract time from dateTime in xquery?

    How to subtract time from dateTime in xquery??
    In ALDSP i tried to use the function xf:add-days but it is showing an error saying invalid function name. I think this namespace is not valid for ALDSP. Is there is any way to add this function in ALDSP???

    xquery functions and operators documentation is here :
    http://www.w3.org/TR/xpath-functions/
    It sounds like you want to ..
    op:subtract-dayTimeDuration-from-dateTime
    this is not an xquery function that you can call, it is an xquery operation defined by the specification
    I believe you can simply use the '-' operator to use that operation.
    <newDateTime>
    { $myDateTime - $myTime }
    </newDateTime>

  • Oarcle Lite cannot subtract negative numbers from date

    Hello
    we have a very strange problem. We have a query that need to convert times between different timezones. So, we have
    In Oracle lite, the query
    select sysdate - (-60/1440) nd from dual returns sysdate + 2 - 60/1440.
    Whenever a negative fraction is subtracted from date, it always adds two days and then adds the fraction. Looks like negative of a negative fraction is not handled correctly in oracle lite.
    Did anyone encounter this problem? We have the system in production and wondering if anyone found a solution.
    Thanks

    HI sd,
    I suspect there's a simpler way, but this works, as seen in the example. Start and finish times are both incremented by one day as the data and formula are filled down the columns to show the effect of crossing the weekend days. Formula (as it appears in row 7) is shown above the table. The Row 2 version is copied below. Cels in column D are formatted as shown in the Inspector.
    D2: =NETWORKDAYS(B2,C2,)+DURATION(,,24*(DUR2DAYS(C2-B2)-INT(DUR2DAYS(C2-B2))),,,)
    Regards,
    Barry

  • Help I need to subtract times to find the difference between two times?

    Hello there, I really need help.
    I'm trying to make this attendance tracking system so that when a user enters his or her ID the system wll remember his/her check in time. However I also need to find out either how late the person is or how early to store their over time and late.
    So I get the time by using a timestamp, so I'm left with a timestamp that I store into the db. But the problem comes when trying to compute for the late or over time. To do that I have to get the normal login/checkin time from the employee schedules table in the db and either subtract that time from the checkInTime to compute for how late or subtract the checkIn time from it to find early.
    The thing is, the schedule is stored in datetime format in the db since the db is sql. Also I have no idea on how to subtract the two dates via java. The month, date and year stored in the sql db are just fillers, all I need computed is the time difference of the hours and minutes between the checkInTime and the schedule.
    I've tried to use datediff: SELECT e.employeeNumber, datediff('hh', startTime, checkInTime) as lateTime from employeeschedules e, timandattendance, contractualemployees c where c.scheduleNumber=e.scheduleNumber and t.employeeNumber=c.employeeNumber and t.checkInNumber=1;
    But it keeps on giving out various errors: You have an error in your sql syntax check your manual that corresponds to your sql server version. for the right syntax to use near , checkInTime) as lateTime from employeeschedules e, timandattendance, contractualemployees c where c.scheduleNumber=e.scheduleNumber and t.employeeNumber=c.employeeNumber and t.checkInNumber=1;
    My sql server is My SQL 5.0.5
    Now I'm thinking of useing Gregorian instead, but I don't know how to use Gregorian and dont know the various methods. Can someone tell me what to do, provide some sample codes and references that I can use to accomplish what I need to do?

    NewtonsApple_2 wrote:
    Now I'm thinking of useing Gregorian instead, but I don't know how to use Gregorian and dont know the various methods. Can someone tell me what to do, provide some sample codes and references that I can use to accomplish what I need to do?it may help...
    GregorianCalendar

  • Subtract today's date from MonthtoDate

    Post Author: LarryA
    CA Forum: Formula
    Is it possible to remove today's date from date formula like Monthtodate, WeektodayfromSunday, Yeartodate.  On Currentdate I was able to do (CurrentDate - 1) but that does not work with the multidate formulas.

    Post Author: LarryA
    CA Forum: Formula
    I have four columns Yesterday Sales, WTD Sales, MTD Sales, YTD Sales  they are grouped by salesrep, when I run my reports each day I don't want to factor in the sales that are taking place today as I mentioned before I handled yesterday sales by using "currentdate -1" but when I try to use crystal's built in functions for "Weektodatefromsunday", "MonthToDate", & "YeatToDate" and place "-1"  I get the following error "A number, currency amount, date, time, or date-time is required here." 
    My fomula looks like this:
    if {CONTHIST.ONDATE}= (MonthToDate) then{@Duration}
    @duration is my sales amount.

  • Trying to subtract days from a date

    Im trying to subtract days from a date.
    When i use this query:
    select sysdate-:p21_DAYS_OLD from dual;
    it displays the correct date but not in the correct format. It is displaying 12-AUG-09 instead of 08/12/2009.
    I tried this query but i get the ORA-01722: invalid number error.
    select to_char(sysdate,'MM/DD/YYYY')-(:p21_DAYS_OLD) from dual;
    Can someone help me please?
    Deanna

    Dclipse03 wrote:
    Im trying to subtract days from a date.
    When i use this query:
    select sysdate-:p21_DAYS_OLD from dual;Just set the NLS_DATE_FORMAT parameter for your session and execute the above query.
    ALTER SESSION SET NLS_DATE_FORMAT='MM/DD/YYYY'
    /

Maybe you are looking for

  • The save tabs prompt no longer comes up please help!

    Every time I closed Firefox before I updated, a prompt would come up that asked me if I wanted to save my tabs then I updated to Firefox 4.0 and now that doesn't happen I tried fixing it but I cant can somebody tell me what settings to change so this

  • Iphone disabled not able to restore it

    hey i have an iphone 5 with ios 7 my iphone is disbled and i have never snyc with itunes i put it in recovery mode but when i m restoring then everytine an error occurs i dont know how to restore it plz help

  • Encore chapter markers which move with clip

    Problem: Encore chapter markers which move with clip CS4 Production Suite XP Pro SP3 I have 9 sequences with each containing 4 Encore chapter markers. As expected in the real world, the end users continually want edits to the sequences. If I razor ou

  • IPhone + Apple iPod Universal Dock?

    Does anyone know if the iPod Universal Dock is really compatible with the iPhone? When I plug my iPhone into the UD it says "This accessory was not made to work with iPhone" and then proceeds to ask if I want to go into Airplane mode to reduce audio

  • CATS_DA Processing Status field

    Hi, Experts: Is there a way to display the description of the processing status field in tcode CATS_DA?  I would rather have the numerical code and text instead of the color-coded icon.   Anyone have a response on this?? thanks, Jack Edited by: HCM_J