Formula for subtracting time from a datetime field

I have a field that is formatted as a datetime field. I just need to know how to subtract 3.5 hours from this time. How do I write a formula in crystal reports kindly help me.
Thanks in advance
Ramakrishna Reddy

This should do the trick...
DateAdd("n", -210, {TableName.DateField})
HTH,
Jason

Similar Messages

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

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

  • 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

  • Need help assigning range for an integer for subtracting time.

    Ok, so I'm having a little trouble getting this program to work. :x Maybe somebody could give me some help on what to do next. I'm new to Java, and I'm trying to write a program using NetBeans 6.9.1, and I ran into a problem. I'm trying to write a program for a time traveler Marty, who is going back in time. The time is set on a 24 hour clock, so am and pm is not an issue.
    I have the program written, but I'm having trouble with the subtraction of the time. Whenever I do the subtract, and the time traveled back (either in hours, minutes or seconds), is bigger than the current time, I just end up with negative numbers. I don't know how to set the value so it will just recycle through the 24 hours, the 60 minutes, or 60 seconds, instead of giving me negative numbers. Any help would be greatly appreciated. Also, I'm not sure how to make the users input italic. Here is what I got so far.
    package timetravel;
    * @author Jeff
    import java.io.*;
    import java.util.*;
    public class Main {
    * @param args the command line arguments
    public static void main(String[] args) {
    int hours, minutes, seconds, hoursback, minutesback, secondsback;
    Scanner keyboard = new Scanner (System.in);
    System.out.println("Hi Marty!");
    System.out.println("Enter current hour:");
    hours = keyboard.nextInt();
    System.out.println("Enter current minute:");
    minutes = keyboard.nextInt();
    System.out.println("Enter current second:");
    seconds = keyboard.nextInt();
    System.out.println("Enter how many hours you want to travel back");
    hoursback = keyboard.nextInt();
    System.out.println("Enter how many minutes you want to travel back");
    minutesback = keyboard.nextInt();
    System.out.println("Enter how many seconds you want to travel back");
    secondsback = keyboard.nextInt();
    System.out.println("When you arrive, the local time will be " + (hours - hoursback)
    + " hours, " + (minutes - minutesback) + " minutes, and " + (seconds - secondsback)
    + " seconds.");

    Well, basically, here's how I want the program to run
    Example program run:
    Hi Marty!
    Enter current hour: 8
    Enter current minute: 12
    Enter current second: 11
    Enter how many hours you want to travel back: 9
    Enter how many minutes you want to travel back: 36
    Enter how many seconds you want to travel back: 39
    When you arrive, the local time will be: 22 hours, 35 minutes, and 32 seconds
    (program input is written in italic)
    instead of how it runs now
    Hi Marty!
    Enter current hour: 8
    Enter current minute: 12
    Enter current second: 11
    Enter how many hours you want to travel back: 9
    Enter how many minutes you want to travel back: 36
    Enter how many seconds you want to travel back: 39
    When you arrive, the local time will be: -1 hours, -24 minutes, and -28 seconds
    I want it to cycle through the 24 hour clock, so if I travel back in time from 18 (1800 or 6pm) and i want to travel back in time 20 hours, I should get 22 (2200 or 10 pm) instead of -2.
    Same with minutes and seconds, except for it to cycle through 60 instead of 24, since there are 60 minutes in an hour, and 60 seconds in a minute. Also, if the minutes end up being negative, I need it to take away one from the hour spot, and so on for the other ones. Hopefully I explained it well enough... Sorry, I'm new to Java.
    Edited by: halo2jak on Sep 7, 2010 12:24 AM

  • BOXI3.0: Formula for subtract/deduct one day or more from date field

    Greetings. Its Alias.
    I have one question. Actually I already post this question but at designer forum.
    I am using SQL.
    Example I have Order Date field and from this field I want to subtract the date by minus one day or two days or three days, etc.
    I got the solution for designer (example):
    DATEADD (dd , -3, EPJ_IPMS.dbo.DO_DATA.DO_DATE_D)
    But at webi level it does not work.
    I also do not understand why at designer and webi level may have different SQL select statement.
    Can someone help me please.
    Best regards,
    Alias

    Hi there Prashant.
    In my case here is I am using Microsoft SQL Server Enterprise Manager and the data is save inside it.
    The Designer and Webi are using same SQL database.
    I also created an Object at Designer and the result is good.
    But say if I don't want to create the object at Designer and let user create their own variables at webi.
    Meaning to educate user to put the variable and formula themselves.
    This is where the SQL statement a I mentioned earlier cannot be used at webi.
    Best Regards,
    Alias

  • Determining a Time ID from a DateTime field

    I have a DT field that I want to break into 1/2hr designators (so 1-48).  Is there a better way to do this than with just a lengthy CASE WHEN (or "old school" IF THEN ELSE)?
    So, for example 03/12/2014 12:05:30am becomes 1 (1st half hour after midnight), while 03/12/2014 11:37:33pm would be 48 (last half hour before midnight).
    Thanks much!
    (fwiw, CR2k8)

    Hi Adam,
    Create a formula with this code:
    If minute({DateTime_Field}) in [0 to 30] then
    Datetime(date({DateTime_Field}),time(hour({DateTime_Field}),0,0))
    else
    If minute({DateTime_Field}) in 31 to 59 then
    datetime(date({DateTime_Field}),time(hour({DateTime_Field}),30,0))
    else
    Datetime(0,0,0,0,0,0)
    You can then group on this formula field and set it to Print for each minute.
    -Abhilash

  • How to calculate Average time from a date field

    Hi All,
    I have a date type field in my table .
    I want to calculate average time for a given country in a select query. Date has to be exculded. Only time has to be taken into consideration.
    Kindly help me.
    Sample data
    india 25-JUN-09 08:12:45
    india 25-JUN-09 09:01:12

    Take which one you want.WITH dates AS
      (SELECT sysdate x FROM dual
        UNION
       SELECT sysdate + 1 +1/24 FROM dual
    SELECT TO_CHAR(to_date(AVG(to_number(TO_CHAR(to_date(TO_CHAR(x,'HH24:MI:SS'),'HH24:MI:SS'),'sssss'))),'sssss'),'hh24:mi:ss')
       FROM dates;
    WITH dates AS
      (SELECT sysdate x FROM dual
        UNION
       SELECT sysdate + 1 +1/24 FROM dual
    SELECT floor(24 * AVG(x- TRUNC(x)))
      || ':'
      || floor(mod(24 * AVG(x- TRUNC(x)),1) * 60)
      || ':'
      || floor(mod(mod(24 * AVG(x- TRUNC(x)),1) * 60,1) * 60)
       FROM dates;By
    Vamsi

  • Help! How to retrive the date and time from MySQL 'datetime' type

    In my MySQL database, I have stored a data type 'DATETIME' as 20070412093012 which is interpreted as 2007-04-12 09:30:12, How to using Java method to retrive it from data base???
    like resultSet.getDate('datetime')????or what is the method?

    Have a look at the API documentation for ResultSet. Which of the methods documented there do you think might be what you need? If you can't tell which is the right one, then post your candidates here and ask a question about them.

  • Query to select value for max date from a varchar field containing year and month

    I'm having trouble selecting a value from a table that contain a varchar column in YYYY-MM format. 
    ex.
    Emp_id Date Cost
    10264 2013-01 5.00
    33644 2013-12 84.00
    10264 2013-02 12.00
    33644 2012-01 680.0
    59842 2014-05 57.00
    In the sample data above, I would like to be able to select the for each Emp_id by the max date. Ex. For Emp_id 10264, the cost should be 12.00.

    create table test (Emp_id int, Date varchar(10), Cost decimal (6,2))
    insert into test values(
    10264, '2013-01', 5.00 ),
    (33644, '2013-12', 84.00 ),
    (10264, '2013-02', 12.00 ),
    (33644, '2012-01', 680.0 ),
    (59842, '2014-05', 57.00 )
    Select Emp_id,[Date],Cost FROM (
    select *,row_number() Over(Partition by Emp_id Order by Cast([Date]+'-1' as Datetime) Desc) rn
    from test)
    t
    WHERE rn=1
    drop table test

  • Bapi for transfering time from cat2

    Is there any bapi which could transfer time entered from webdynpro created for cat2 into catsdb
    thanks n regards

    Is this a custom WebDynpro or the delivered Record Working Time service? Pl take a look at the function gorup HRXSS_CAT_WEBDYNP via SE80.
    Arya

  • Formula for scanning image from book to have at 1200 pixel width

    I have to scan some images from a book for a website. The images in the book are various sizes ie 4" x 6". I need to have the final images, for the website, at 1200 pixels wide, 72 dpi. Is there a formula to use when scanning so that the scanned images will be 1200 dpi in width or very close to that.
    TIA

    Measure with width of the photo to be scanned and use the following formula: 
    Scanning dpi= 1200 divided by the width of the photo in inches
    Scanning a 4x6 photo you would scan at 200 dpi.  Because 200 dpi x 6 inches = 1200 pixels.
    OT

  • Bex Formula for calcualting Value from Quantity & Price

    Hello,
    In my query I need to calculate the value by multiplying Quantity available in my cube and net price in my material master attribute.
    How can I do this?
    I tried creating a formula variable for net price and multipied it with Qty but it still says the formula is incorrect.
    Any suggestions please??

    I created a formula variable using replacement path as processing type, selected the reference characteristics as 0Material.
    Under replacement rule selected replace variable with "infoobject", replace with "Attribute Value" and selected my attribute infoobject "0Net_Price"
    In my calculated key figure I try to use this formula variable and multiply it with Qty,but it still gives a warning element not defined properly.
    Can you let me know if I have missed out any step in the formula variable creation??
    How is the final unit of the Calculated key figure determined? Does it take the unit of net price ??

  • The update iTunes 11.2 keeps downloading for 7 time from app store

    my question is how can i stop the mac store downloading itunes 11.2 update on my imac

    JUST A UPDATE FROM 469AW YOU CAN'T UNINSTALL UPDATE IT IS PART OF (10.9.3)

Maybe you are looking for

  • Adobe Camera Raw window-Only full screen?

    I use Elements 7.0.  In an attempt to improve my photography, I've been concentrating on getting as close to a proper exposure in camera using zone system etc.  To further get close to the appropriate exposure after the shot is taken, I've begun to s

  • A/c modifier@a/c key def

    hi, pls make me know abt a/c modifier@a/c key def in fi&sd integration regards jana

  • Create a Job for a transaction dynamically through ABAP program.

    Hello Experts, Can a job be created for a transaction dynamically, say for example i have a parameter on selection screen which will take the name of the transaction and then i have to create a job to run that transcation. Plz provide sample code. Re

  • Capital One QuickSilver One Annual Fee Waiver/Upgrade

    The frontline CSRs aren't able to see all offers available.   Contact the Cap One EO and see if you are able to get the fee waived or if you are eligible to PC to the regular QS.   My situation was similar to yours.   I had a Household Bank CC with a

  • Simple table mapping

    I have a source table and a target table with the same name in different schemas! How can I do to create a simple mapping between this table? Mapping editor raname the target table with suffix "_1" and the deploy procedure give me obviously an error