Date time calculating

I'm a total newbie, It's late and I can't figure it out so here it is.
How would I subtract 5 minutes from the following?
Date today = Calendar.getInstance().getTime();
I have been searching and reading for the past hour, is there an easy way to manipulate dates in Java?

import java.util.Calendar;
import java.util.Date;
public class Dates {
     public Dates() {
          super();
          // TODO Auto-generated constructor stub
      * @param args
     public static void main(String[] args) {
          // TODO Auto-generated method stub
          Calendar calendar = Calendar.getInstance();
          int minute = calendar.get(Calendar.MINUTE);
          System.out.println(minute);
          Date today = calendar.getTime();
          calendar.set(Calendar.MINUTE, minute-5);
          System.out.println(calendar.get(Calendar.MINUTE));
          Date customDate = calendar.getTime();
          System.out.println(customDate);
}

Similar Messages

  • Basic and scheduling  dates & time calculation in process order creation

    Hi guru's,
    i have one requirement, i need to calculate and display the basic and scheduled dates & times based on the given input i.e material , plant , process order type , quantity , UOM and scheduling type ( for corresponding scheduling type user will provide either start date or finish date ) using RFC. can  u plz provide any function module for this purpose or logic for calculating the same  , as i am working on version 4.7ee .
    Awaiting for a quick response.
    Regards,
    Madan

    Dear Rohan,
    1.Check the length of break timings defined in the resource that is assigned in the phase.
    2.Check in OPUZ whether for the process order type and plant combination whether scheduling is to include the break time also
    (whether the check box for scheduling with breaks) is included.
    Check and revert back.
    Regards
    Mangalraj.S

  • [8i] Date/Time calculation problem...

    So, I am currently facing a situation where I need to calculate the total hours a workstation is in use for each day in a particular time period. I have a table with the log of each time each workstation is used. The problem is, a workstation can be used for any amount of time, starting on any day and ending on any day. This means that a particular entry in the log can span multiple days. I'm not sure how to split the difference between the end date/time of an entry and the start date/time of the entry over multiple days.
    Here's a sample table and some sample data for what I'm trying to do:
    -- Note: in reality, this table contains more columns
    CREATE TABLE     my_hrs
    (     record_id     NUMBER     NOT NULL
    ,     sdatetime     DATE     
    ,     edatetime     DATE     
    ,     workstation     VARCHAR2(4)
         CONSTRAINT my_hrs_pk PRIMARY KEY (record_id)
    -- Note: sdatetime, edatetime, and workstation CAN all be NULL, though I won't provide
    -- any sample data for these situations since I want to ignore them in my results
    -- Additionally, there are hundreds of workstations, but I'm only using 2 to simplify the sample data
    INSERT INTO     my_hrs
    VALUES (12345,TO_DATE('03/01/2010 08:00','mm/dd/yyyy HH24:MI'),TO_DATE('03/01/2010 13:35','mm/dd/yyyy HH24:MI'),'123A');
    INSERT INTO     my_hrs
    VALUES (13427,TO_DATE('03/01/2010 08:10','mm/dd/yyyy HH24:MI'),TO_DATE('03/01/2010 10:02','mm/dd/yyyy HH24:MI'),'321B');
    INSERT INTO     my_hrs
    VALUES (21543,TO_DATE('03/01/2010 14:07','mm/dd/yyyy HH24:MI'),TO_DATE('03/01/2010 16:30','mm/dd/yyyy HH24:MI'),'123A');
    INSERT INTO     my_hrs
    VALUES (22412,TO_DATE('03/01/2010 10:15','mm/dd/yyyy HH24:MI'),TO_DATE('03/01/2010 15:30','mm/dd/yyyy HH24:MI'),'321B');
    INSERT INTO     my_hrs
    VALUES (11976,TO_DATE('03/01/2010 17:00','mm/dd/yyyy HH24:MI'),TO_DATE('03/02/2010 02:30','mm/dd/yyyy HH24:MI'),'123A');
    INSERT INTO     my_hrs
    VALUES (34215,TO_DATE('03/01/2010 22:10','mm/dd/yyyy HH24:MI'),TO_DATE('03/02/2010 04:30','mm/dd/yyyy HH24:MI'),'321B');
    INSERT INTO     my_hrs
    VALUES (24789,TO_DATE('03/02/2010 13:00','mm/dd/yyyy HH24:MI'),TO_DATE('03/05/2010 02:30','mm/dd/yyyy HH24:MI'),'123A');
    INSERT INTO     my_hrs
    VALUES (31542,TO_DATE('03/02/2010 21:30','mm/dd/yyyy HH24:MI'),TO_DATE('03/04/2010 10:30','mm/dd/yyyy HH24:MI'),'321B');Based on my sample data above, these are the results I want to see:
    WORKSTATION     DATE          HRS_IN_USE
    123A          3/1/2010     14.96667
    321B          3/1/2010     8.95000
    123A          3/2/2010     13.50000
    321B          3/2/2010     7.00000
    123A          3/3/2010     24.00000
    321B          3/3/2010     24.00000
    123A          3/4/2010     24.00000
    321B          3/4/2010     10.50000
    123A          3/5/2010     2.50000
    321B          3/5/2010     0.00000Is this possible? (Please note, if the workstation was not used on a particular day, I want it to show 0 hours for that workstation for that day). Another thing to note is that I'm working with Oracle 8i.
    Thanks in advance for the help!

    Thanks, Frank, your explanation helped. My main problem was just that I couldn't picture what that line of the query was doing, even working from the inside out. I learn better through visual and hands-on methods, so to really understand, I had to look at the cross-join of a and h and go line by line. (In case there's anybody who looks at this post in the future and learns like I do, I've posted that data below).
    This definitely solves my problem!
    >
    By the way, this query is full of things that could be done better in later versions of Oracle. Generating table a is just one of them. Starting in Oracle 9, you can do a CONNECT BY query on dual to generate exacly how many rows you need. You never have to worry about an upper bound, and it's much faster than using ROWNUM. From time to time you might gently remind the people who decide these things that you're using a very old, unsupported version of Oracle, and that everyone could be more productive if you upgraded.
    >
    I could go on and on on this topic.... we have tried and continue to try to convince the powers that be to pay for the upgrades... if it were just Oracle that needed to be upgraded, we might actually have a chance at succeeding. As it is, ...ha.
    TABLE A (FROM SUB-QUERY)
    a_date          next_date
    3/1/2010     3/2/2010
    3/2/2010     3/3/2010
    3/3/2010     3/4/2010
    3/4/2010     3/5/2010
    3/5/2010     3/6/2010
    TABLE H (MY_HRS)          
    record_id     sdatetime     edatetime     workstation
    10000          2/28/2010 18:00     3/1/2010 5:30     123A
    12345          3/1/2010 8:00     3/1/2010 13:35     123A
    13427          3/1/2010 8:10     3/1/2010 10:02     321B
    21543          3/1/2010 14:07     3/1/2010 16:30     123A
    22412          3/1/2010 10:15     3/1/2010 15:30     321B
    11976          3/1/2010 17:00     3/2/2010 2:30     123A
    34215          3/1/2010 22:10     3/2/2010 4:30     321B
    24789          3/2/2010 13:00     3/5/2010 2:30     123A
    31542          3/2/2010 21:30     3/4/2010 10:30     321B
    CROSS-JOIN TABLE A WITH TABLE H                                             (and calculations done by the query below)     
    record_id     sdatetime     edatetime     workstation     a_date          next_date     LEAST (h.edatetime, a.next_date)     GREATEST (h.sdatetime, a.a_date)     GREATEST(TO_NUMBER(L-G),0)
    10000          2/28/2010 18:00     3/1/2010 5:30     123A          3/1/2010     3/2/2010     3/1/2010 5:30                    3/1/2010 0:00                    0.229166667
    10000          2/28/2010 18:00     3/1/2010 5:30     123A          3/2/2010     3/3/2010     3/1/2010 5:30                    3/2/2010 0:00                    0.00000
    10000          2/28/2010 18:00     3/1/2010 5:30     123A          3/3/2010     3/4/2010     3/1/2010 5:30                    3/3/2010 0:00                    0.00000
    10000          2/28/2010 18:00     3/1/2010 5:30     123A          3/4/2010     3/5/2010     3/1/2010 5:30                    3/4/2010 0:00                    0.00000
    10000          2/28/2010 18:00     3/1/2010 5:30     123A          3/5/2010     3/6/2010     3/1/2010 5:30                    3/5/2010 0:00                    0.00000
    12345          3/1/2010 8:00     3/1/2010 13:35     123A          3/1/2010     3/2/2010     3/1/2010 13:35                    3/1/2010 8:00                    0.23264
    12345          3/1/2010 8:00     3/1/2010 13:35     123A          3/2/2010     3/3/2010     3/1/2010 13:35                    3/2/2010 0:00                    0.00000
    12345          3/1/2010 8:00     3/1/2010 13:35     123A          3/3/2010     3/4/2010     3/1/2010 13:35                    3/3/2010 0:00                    0.00000
    12345          3/1/2010 8:00     3/1/2010 13:35     123A          3/4/2010     3/5/2010     3/1/2010 13:35                    3/4/2010 0:00                    0.00000
    12345          3/1/2010 8:00     3/1/2010 13:35     123A          3/5/2010     3/6/2010     3/1/2010 13:35                    3/5/2010 0:00                    0.00000
    13427          3/1/2010 8:10     3/1/2010 10:02     321B          3/1/2010     3/2/2010     3/1/2010 10:02                    3/1/2010 8:10                    0.07778
    13427          3/1/2010 8:10     3/1/2010 10:02     321B          3/2/2010     3/3/2010     3/1/2010 10:02                    3/2/2010 0:00                    0.00000
    13427          3/1/2010 8:10     3/1/2010 10:02     321B          3/3/2010     3/4/2010     3/1/2010 10:02                    3/3/2010 0:00                    0.00000
    13427          3/1/2010 8:10     3/1/2010 10:02     321B          3/4/2010     3/5/2010     3/1/2010 10:02                    3/4/2010 0:00                    0.00000
    13427          3/1/2010 8:10     3/1/2010 10:02     321B          3/5/2010     3/6/2010     3/1/2010 10:02                    3/5/2010 0:00                    0.00000
    21543          3/1/2010 14:07     3/1/2010 16:30     123A          3/1/2010     3/2/2010     3/1/2010 16:30                    3/1/2010 14:07                    0.09931
    21543          3/1/2010 14:07     3/1/2010 16:30     123A          3/2/2010     3/3/2010     3/1/2010 16:30                    3/2/2010 0:00                    0.00000
    21543          3/1/2010 14:07     3/1/2010 16:30     123A          3/3/2010     3/4/2010     3/1/2010 16:30                    3/3/2010 0:00                    0.00000
    21543          3/1/2010 14:07     3/1/2010 16:30     123A          3/4/2010     3/5/2010     3/1/2010 16:30                    3/4/2010 0:00                    0.00000
    21543          3/1/2010 14:07     3/1/2010 16:30     123A          3/5/2010     3/6/2010     3/1/2010 16:30                    3/5/2010 0:00                    0.00000
    22412          3/1/2010 10:15     3/1/2010 15:30     321B          3/1/2010     3/2/2010     3/1/2010 15:30                    3/1/2010 10:15                    0.21875
    22412          3/1/2010 10:15     3/1/2010 15:30     321B          3/2/2010     3/3/2010     3/1/2010 15:30                    3/2/2010 0:00                    0.00000
    22412          3/1/2010 10:15     3/1/2010 15:30     321B          3/3/2010     3/4/2010     3/1/2010 15:30                    3/3/2010 0:00                    0.00000
    22412          3/1/2010 10:15     3/1/2010 15:30     321B          3/4/2010     3/5/2010     3/1/2010 15:30                    3/4/2010 0:00                    0.00000
    22412          3/1/2010 10:15     3/1/2010 15:30     321B          3/5/2010     3/6/2010     3/1/2010 15:30                    3/5/2010 0:00                    0.00000
    11976          3/1/2010 17:00     3/2/2010 2:30     123A          3/1/2010     3/2/2010     3/2/2010 0:00                    3/1/2010 17:00                    0.29167
    11976          3/1/2010 17:00     3/2/2010 2:30     123A          3/2/2010     3/3/2010     3/2/2010 2:30                    3/2/2010 0:00                    0.10417
    11976          3/1/2010 17:00     3/2/2010 2:30     123A          3/3/2010     3/4/2010     3/2/2010 2:30                    3/3/2010 0:00                    0.00000
    11976          3/1/2010 17:00     3/2/2010 2:30     123A          3/4/2010     3/5/2010     3/2/2010 2:30                    3/4/2010 0:00                    0.00000
    11976          3/1/2010 17:00     3/2/2010 2:30     123A          3/5/2010     3/6/2010     3/2/2010 2:30                    3/5/2010 0:00                    0.00000
    34215          3/1/2010 22:10     3/2/2010 4:30     321B          3/1/2010     3/2/2010     3/2/2010 0:00                    3/1/2010 22:10                    0.07639
    34215          3/1/2010 22:10     3/2/2010 4:30     321B          3/2/2010     3/3/2010     3/2/2010 4:30                    3/2/2010 0:00                    0.18750
    34215          3/1/2010 22:10     3/2/2010 4:30     321B          3/3/2010     3/4/2010     3/2/2010 4:30                    3/3/2010 0:00                    0.00000
    34215          3/1/2010 22:10     3/2/2010 4:30     321B          3/4/2010     3/5/2010     3/2/2010 4:30                    3/4/2010 0:00                    0.00000
    34215          3/1/2010 22:10     3/2/2010 4:30     321B          3/5/2010     3/6/2010     3/2/2010 4:30                    3/5/2010 0:00                    0.00000
    24789          3/2/2010 13:00     3/5/2010 2:30     123A          3/1/2010     3/2/2010     3/2/2010 0:00                    3/2/2010 13:00                    0.00000
    24789          3/2/2010 13:00     3/5/2010 2:30     123A          3/2/2010     3/3/2010     3/3/2010 0:00                    3/2/2010 13:00                    0.45833
    24789          3/2/2010 13:00     3/5/2010 2:30     123A          3/3/2010     3/4/2010     3/4/2010 0:00                    3/3/2010 0:00                    1.00000
    24789          3/2/2010 13:00     3/5/2010 2:30     123A          3/4/2010     3/5/2010     3/5/2010 0:00                    3/4/2010 0:00                    1.00000
    24789          3/2/2010 13:00     3/5/2010 2:30     123A          3/5/2010     3/6/2010     3/5/2010 2:30                    3/5/2010 0:00                    0.10417
    31542          3/2/2010 21:30     3/4/2010 10:30     321B          3/1/2010     3/2/2010     3/2/2010 0:00                    3/2/2010 21:30                    0.00000
    31542          3/2/2010 21:30     3/4/2010 10:30     321B          3/2/2010     3/3/2010     3/3/2010 0:00                    3/2/2010 21:30                    0.10417
    31542          3/2/2010 21:30     3/4/2010 10:30     321B          3/3/2010     3/4/2010     3/4/2010 0:00                    3/3/2010 0:00                    1.00000
    31542          3/2/2010 21:30     3/4/2010 10:30     321B          3/4/2010     3/5/2010     3/4/2010 10:30                    3/4/2010 0:00                    0.43750
    31542          3/2/2010 21:30     3/4/2010 10:30     321B          3/5/2010     3/6/2010     3/4/2010 10:30                    3/5/2010 0:00                    0.00000
    (Then, the query sums up the last column in the "table" above, grouped by a_date and workstation).

  • Date/Time Calculation ?

    I have a query that hopfully someone can resolve.
    The below select statment returns the below column and as you can see, two of these columns hold date/time information
    select IR.doc_no, AR.line_no, AR.step_no, AR.description, AR.app_sign, AR.approval_status, ir.dt_doc_rev, AR.app_date
    from APPROVAL_ROUTING AR,
    ISSUE_REFERENCE IR
    where
    AR.key_ref = IR.key_ref
    and ar.key_ref like '%1050387%'
    order by ar_step_no
    ** Output **
    Doc_No     Line_No     Step_No     Description     App_Sign     Approval_Status     Dt_Doc_Rev          App_Date
    1050387     4     10     P          B          Approved     2010-04-16-15.52.31     2010-04-16-17.00.01
    1050387     1     20     C          P          Approved     2010-04-16-15.52.31     2010-04-19-13.22.18
    1050387     2     30     Q          A          Approved     2010-04-16-15.52.31     2010-04-19-13.57.29
    1050387     5     40     P          H          Approved     2010-04-16-15.52.31     2010-04-20-13.14.34
    1050387     6     50     S          B          Approved     2010-04-16-15.52.31     2010-04-20-14.47.22
    1050387     7     50     P          H          Approved     2010-04-16-15.52.31     2010-04-20-13.49.30
    1050387     3     60     S          H          Approved     2010-04-16-15.52.31     2010-04-21-12.15.06
    1050387     8     70     A          (          Approved     2010-04-16-15.52.31     2010-05-06-10.14.52
    What I want to do is calculate (and output in a separate column) in days/hours how long each step took (Step_No). So as an example, step 10 > step 20 took '1 hour 7 mins 30 sec'. Any assistance would be greatly appreciated.

    Hi,
    If your column is not a timestamp, you can cast it to timestamp and use ths available features by Oracle.
    with data as(
    select 1050387 doc_no,
           4 line_no,
           10 step_no,
           'P' descripti,
           'B' app_sign,
           'Approved' approval_status,
           cast(to_date('2010-04-16-15.52.31', 'YYYY-MM-DD-HH24.MI.SS') as
                timestamp) Dt_Doc_Rev,
           cast(to_date(' 2010-04-16-17.00.01', 'YYYY-MM-DD-HH24.MI.SS') as
                timestamp) app_date
      from dual
    select doc_no,
           line_no,
           step_no,
           descripti,
           app_sign,
           approval_status,
           extract(day from(app_date - Dt_Doc_Rev)) Days,
           extract(hour from(app_date - Dt_Doc_Rev)) hours,
           extract(minute from(app_date - Dt_Doc_Rev)) minutes,
           extract(second from(app_date - Dt_Doc_Rev)) seconds
      from databtw i am on
    Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.1.0
    Connected as scottRegards,
    Bhushan

  • Date&time Calculation with respect to Service&Response Profile

    Hi all,
    The scenario is  -  we are creating service request which is having service profile and response profile , according to these the First response time and to do by time are getting calculated. In this calculation system is considering the week ends,working hours per day and holidays ( which are defined in customizing).
    Now i want to do the same kind of calculation for some other purpose. like i have two timestamps i want to find exact time difference between those two by considering service profile and response profile.
    Example:
    Let's consider my service profile is 5X8 ( Mon - Friday and 8 hours per Day 09:00:00 to 17:00:00)
    and the response profile is 10X15 ( response should be in 10 hours and to be completed by 15 Hours )
    Suppose I'm creating the Service request by 23.03.2010  09:00:00 then system will give the response time like
    24.03.2010 11:00:00 ( on or before )
    ( it took 8 hours from 23.03.2010 and 2 hours from 24.03.2010 )
    Please give idea to get this logic how system calculates by considering service profile and response profile.
    Regards
    Chand

    Hi chand,
    Whateever logic you have told is 80 % correct. But you also need to consider the following thing.
    1. You need to define the factoy calender cosidering the holiday in the t code SCAL. and that need to be attched to your service profile
    2. Suppose your first respose time is 10 hours and 1st resolution time is 15  hours, it also needs to consider the holidays.
    Eg. if the Service call come on friday at 3.00PM , then the resopnse should go by Monday 5.00PM. Response will be by 2.00 PM on Tuesday (Provided these days are not the hoildays).
    Hope this clears your doubts.
    Regards,
    Uday Borse

  • Date-Time Arithmetic

    I'm a long time Excel user.  I want to import a few of my Excel spreadsheets into Numbers so I can then take advantage of iCloud Drive to add data to these particular Numbers spreadsheet from my iPad Air 2 (latest version of IOS 8).  Any modifications to the Numbers spreadsheet will be done on my 2 year old 27" iMac running the latest version of Yosemite and Numbers.
    All my Excel spreadsheets have imported to Numbers without a hitch except the one that uses Date-Time arithmetic.  Excel allows you to put a date in one cell and time in another and to add the two to create a number based on January 1, 1904 as the reference.  This makes it easy to do Date-Time Arithmetic.  As best I can tell you can only do this in Numbers if you enter a date and a time in each cell, which is both cumbersome and time consuming.  I can't seem to find any way around this.  Is there a way to add a date cell to a time cell in Numbers similar to Excel that I haven't found?  Thanks.

    Klavezzo,
    Date-Time values are where Numbers diverges most from Excel in the things that I use frequently. I no longer use Excel, so the differences don't affect me the way they might affect you or others. In Numbers, every Date has a Time associated with it, and every Time has a Date associated with it. They always exist together.
    There are functions to strip out individual elements of the Date-Time value, if you need to: YEAR, MONTH, DAY, HOUR, MINUTE and TIMEVALUE. The first 5 are self explanatory, TIMEVALUE returns the decimal fraction of a day corresponding to the Time portion of the Date-Time value.
    A Duration value can be useful if you prefer not to work in decimal fractions of a day, and it is especially important for Date-Time difference calculations.
    The key things to remember about Date-Time calculations are 1. You can't add two Date-Time values, and 2. The result of a Date-Time subtraction is a Duration, and 3. To add to a Date-Time value, you can either add a Duration or you can add a numeric value of days, and decimal fractions of a day, for the time portion.
    As with most values in Numbers, you can change how a value is displayed with formatting, but you can't change the data type with formatting. The only exception that I can think of is that when a value is formatted as Text. Then it no longer can be manipulated as a value, so it truly is altered internally.
    If you give us some examples of your calculations, we can suggest ways to deal with them in Numbers.
    Jerry

  • Date VS Date Time in Calculated Field

    I have a property for a patients records called Date of Birth. On the table defining it I saved it as a "date" type and It displays only
    the date on the screen as I would like. For some reason though when I needed a calculated field in the Medication record I added a property to the patient records table that concatenated two fields BirthDate and the Age. I used the following code and then
    added an other screen data item on the medication screen to pull the DoBA property up but got a Date/Time instead of just a Date.
    partial void DoBA_Compute(ref string result)
    // Set result to the desired field value
    result = "DoB:" + BirthDate + " Age:" + Age;
    //This is for the property "Date of Birth and Age"
    //I also used the following code to calculate "Age"
    partial void Age_Compute(ref int result)
    // Set result to the desired field value
    int age = DateTime.Now.Year - BirthDate.Year;
    if (BirthDate > DateTime.Now.AddYears(-age)) age--;
    result = age;
    Images

    I'm using cast instead of Convert.ToInt because the last round to value to upper int if value > 0.5 or to lower if value < 0.5 ( I don't remember now if equal goes to < or > ... read function doc ) while Cast to int do not round the value.
    In my code the day of the birthday
    still
    marks
    the
    previous
    age,
    from the
    day after
    one more year.
    by adding
    +
    1
    age
    increases
    by the
    day
    of the birthday

  • Adding Date/Time Field + X Number of Days - Basic Calculation Question

    I am assuming this is a basic calculation question. New to Adobe LiveCycle Forms.
    I have a simple form containing a table. The table appears as such:
    Text
    Formatted as Date/Time Fields
    Header 3
    Monday
    user wil choose the beginning date (Date/Time) this is DateTimeField1
    Tuesday
    this should calculate DateTimeField1 + 1
    Wednesday
    this should calculate DateTimeField1 + 2
    Thursday
    this should calculate DateTimeField1 + 3
    Friday
    this should calculate DateTimeField1 + 4
    Saturday
    this should calculate DateTimeField1 + 5
    Sunday
    this should calculate DateTimeField1 + 6
    Calculations are performed after the date is chosen for Monday. My mind tells me the simple calculation of DateTimeField1 + 1 is not going to work (and in fact doesn't!) as it needs to change Monday to a number first. I saw on another thread the following:
    Num2Date(Date2Num(Date(DateTimeField1), "DD.MM.YYYY")+7, "DD.MM.YYYY")
    Thought this was going to get me close. No cigars though!
    Any quick help is greatly appreciated. And since I am new to this, details about what needs to be changed would be great too!
    Thanks

    Here an addition for you date field.
    This FormCalc script in the exit:Event will check it the selected date is on a monday.
    If not it will go the days back until the last monday.
    var Selection = Date2Num($.formattedValue, DateFmt(2))
    var WeekDay = Num2Date(Selection, "E")
    var NewDate
    if (WeekDay eq 1) then
              NewDate = Selection - 6
    elseif (WeekDay eq 3) then
              NewDate = Selection - 1
    elseif (WeekDay eq 4) then
              NewDate = Selection - 2
    elseif (WeekDay eq 5) then
              NewDate = Selection - 3
    elseif (WeekDay eq 6) then
              NewDate = Selection - 4
    elseif (WeekDay eq 7) then
              NewDate = Selection - 5
    else
              NewDate = Selection
    endif
    $ = Num2Date(NewDate, "EEE DD.MM.YYYY")
    Hope this helps, too.

  • I want to do calculation between date/time fields

    Post Author: fmonsma
    CA Forum: Publishing
    Hi, I already post this question a couple of times but I can't make it work.
    IST:I  have converted a date/time field to a field so i can make calculation on it but i don't know ho to convert it to minuts;seconds.
    Starttime        - Endtime           - Convert begin - Convertend - convertsumbegin - convertsumend - difference between31-7 12:39:00 - 31-07 13:08:00   - 123900    -    010800 - 123.900 - 10.800 -  -113.100
    SOLL
    Start time - Endtime - Differencebetween12:39 - 13:08 - 0:29
    If i make this calculation in Excel it's very simple and works perfect. I want this in my Webintelligence report but don't know which functions/script i need to have. Thanks;

    Post Author: jsanzone
    CA Forum: Publishing
    fmonsma:
    Based on the sample data that you provide, it appears that you want to be able to report data based on the number of minutes that have elapsed between "Starttime" and "Endtime".  Looking at the WebI Variable Editor functions in the "Date & Time" functions list, it does not appear that there are any capability to determine elapsed minutes (it appears that the only "time" of the "Date & Time" functions is the "CurrentTime" function, not much else in regards to time...)
    You don't mention the database platform you are using, however, if you happen to be using MS SQL Server, then they have the DATEDIFF function.  Within DATEDIFF the parameters are: DATEDIFF ( datepart , startdate , enddate ), where datepart specificies any of the following facts:  Year, quarter, Month, dayofyear, Day, Week, Hour, minute, second, millisecond
    Bottom line, you will most likely not be able to rely on WebI to determine the elapsed seconds and you'll have to set up an object within your Universe to do the work on the database server and bring it across to your reports that way.

  • Time calculation from one date to some other date

    Hello,
    I want to time calcualtion from one date to other date period.
    for calculating total hr's from one date to other date.plz let me know the logic.
                           Date                      Time
    Eq:  1st date:   22.05.2008             01.10.00
          2nd date:   25.05.2008             12.10.00
    I want the total hrs from 22.05 to 25.05 like i need result as
    from 22 to 25 total hrs based on the time given.

    Hello,
    Instead of FM..We can achieve by the following program...
    REPORT YRT_TEST1.
    parameters : date1 like sy-datum,
    date2 like sy-datum.
    data: days(3) type n.
    data: years(10) type p decimals 3.
    start-of-selection.
    days = date2 - date1.
    years = days / 365.
    write: / days,
    years.
    Now Multiply 24  to days to get hours and the multiply with 60*60 to get the seconds
    ***************Reward points,if found useful

  • Calculate Date/Time Difference in a Calculated Column Omitting Weekends, Holidays and Non-Working Hours

    I am looking for a formula to use in a calculated column that calculates the difference between two date/time fields while excluding weekends, holidays and non-working hours
    6/1/2010 9:43 AM - 6/7/2010 1:45 PM
    Here is the closest that I have gotten; however, this formula gives me a result of 96:
    =IF(AND((WEEKDAY([Resolved Date],2))<(WEEKDAY(Created,2)),((WEEKDAY(Created,2))-(WEEKDAY([Resolved Date],2)))>1),(((DATEDIF(Created,[Resolved Date],"D")))-(FLOOR((DATEDIF(Created,[Resolved Date],"D")+1)/7,1))-3),(((DATEDIF(Created,[Resolved Date],"D")))-(FLOOR((DATEDIF(Created,[Resolved
    Date],"D")+1)/7,1)*2))*24)
    Any and all assistance is greatly appreciated!

    I don't know how to exclude holidays but i exclude weekends(Sat&Sun)-
    IF(ISERROR(DATEDIF([Start Date],[End Date],”d”)),””,(DATEDIF([Start Date],[End Date],”d”))+1-INT(DATEDIF([Start Date],[End Date],”d”)/7)*2-IF((WEEKDAY([End Date])-WEEKDAY([Start
    Date]))<0,2,0)-IF(OR(AND(WEEKDAY([End Date])=7,WEEKDAY([Start Date])=7),AND(WEEKDAY([End Date])=1,WEEKDAY([Start Date])=1)),1,0)-IF(AND(WEEKDAY([Start Date])=1,(WEEKDAY([End Date])-WEEKDAY([Start Date]))>0),1,0)-IF(AND(NOT(WEEKDAY([Start Date])=7),WEEKDAY([End
    Date])=7),1,0))
    -Thanks
    Swapnil

  • Preserving date in time calculations in Numbers

    I've scoured the discussion forums and I'm stuck on this one.
    When I enter a time in a cell (e.g., '3:00 PM' in A1) and do a calculation using TIME and TIMEVALUE which results in a value in B2, I noticed that the date changes. Without explicitly saying so, the date in A1 defaults to today's date. After doing the calculation, the date in B2 ends up as January 1, 1904. Any idea how the date can be retained, or, even better, completely ignored? The root problem is that when doing conditional formatting on a time value, the date is also taken into consideration. If the date is ignored, my time calcuations would be correct. Since the date is not ignored, my calculations are thrown off by the date constantly being changed back to 1/1/1904.
    What I have done as a work around is to enter the original time as '=TIME(5,44,0)', which defaults the date to 1/1/1904. But, it would be nice if I could just enter '5:44:00' and not have to worry about the date component.
    Alternately, if the date can be retained in the TIME and TIMEVALUE calculations, it would also solve my problem.

    Jinxed,
    I'm not completely clear on your equations, based on your description. It would be better if you would quote your expressions exactly so we could examine them.
    If you have a Date/Time value in A and write =TIMEVALUE (A) in B, there will be no date present in B whatsoever, so it won't change. You can still get it from A if you need it and B will contain the fraction of a day represented by the time of day in A.
    Jerry

  • Date and Time Calculation in Bex.

    Hi All,
    I want to calculate the number of days and the time by subtracting from two dates and time.
    Ex : 27-Jan-2009 10.30AM  - 20-Jan-2009 10.00AM
    Result : 6 days 23 hrs
    In my ODS, i have FROM date, time and TO date,time are in Characteristics.
    is it possible do it in the Query designer.
    Pls provide me the steps.
    Thanks,
    Ram.
    Edited by: Ram Siva on Jan 27, 2009 6:29 AM

    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

  • Date and Time Calculation

    Dear all.
       I need a function that receives a Date / Time and another Date and calculates the the sum of those values.
    Best Regards,
    Thanks In advanced.
    PMR

    Hai Rodrigues,
    The function module CALCULATE_DATE also adds/subtracts days and months to/from a date. The following website also demonstrates a number of ways to add days/months taking into account working and non working days if that is any use. http://www.sapdevelopment.co.uk/tips/date/datehome.htm
    CALL FUNCTION 'CALCULATE_DATE'
    EXPORTING
    DAYS = '0'
    months = '01'
    start_date = p_date
    IMPORTING
    result_date = p_date.
    You can even check this function modules, it works fine.
    Function Module Name:: ADD_TIME_TO_DATE
    Short Description :: Adds months/days/years to date.
    Entering a negative value will subtract from the date.
    Parameters ::
    Exporting:
    I_IDATE : Initial date
    I_TIME : Quantity to add
    I_IPRKZ : Unit of time(D:day, M:month, W:week, Y:year)
    Importing:
    O_IDATE : OUTPUT DATE
    Regards,
    Srikanth.

  • Date / Time System fields - inconsistent

    This is a weird one...please bear with me
    Before I begin...note that this is not a problem that is difficult to fix, I'm just interested in better understanding why the system fields are behaving the way they are.
    We have 20 or so programs that use a function module to create a file header that includes a date/time stamp.  The programs also place a trailer with a date/time stamp that should match the one in the header.  However, the programmer used different system fields (after a GET TIME statement) to create the date/time stamp in the trailer.  On occasion, the date/time stamp comes out different. 
    Here's the code (sry about all caps):
      GET TIME.
      CONCATENATE SY-DATUM SY-UZEIT INTO BATCHID.
      CALL FUNCTION 'Z_YADAYADA'
           EXPORTING
                FILE_ID              = P_FILEID
                REFRESH_TYPE         = P_REFTYP
                START_PERIOD         = START_PER
                END_PERIOD           = END_PER
           IMPORTING
                STRING255            = OUTPUTSTRING
           EXCEPTIONS
                INVALID_REFRESH_TYPE = 1
                INVALID_BATCH_ID     = 2.
      ...sy-subrc check...
      TRANSFER OUTPUTSTRING TO P_FILE1.  <--header output
      CONCATENATE L_TRL BATCHID COUNT T_TOTAL SPACE
                  INTO OUTPUTSTRING SEPARATED BY L_DEL.
      CONDENSE OUTPUTSTRING NO-GAPS.
      TRANSFER OUTPUTSTRING TO P_FILE1.  <--trailer output
    inside function module *****
      CONCATENATE: SY-DATLO SY-TIMLO INTO DATESTAMP,
                   SY-SYSID SY-MANDT INTO MACHINE_NAME.
      CONDENSE: DATESTAMP, MACHINE_NAME NO-GAPS.
      CONCATENATE C_HDR DATESTAMP FILE_ID MACHINE_NAME
                  SY-CPROG ' ' REFRESH_TYPE START_PERIOD
                  END_PERIOD DATESTAMP
                  INTO STRING255 SEPARATED BY '~'.
      CONDENSE: STRING255 NO-GAPS.
    You can see that the function uses SY-DATLO and SY-TIMLO for creation of the header, while SY-DATUM and SY-UZEIT are used for the trailer.  What's wierd is that sometimes the trailer has a date/time stamp that is 1 second <b>greater</b> than the header, despite the fact that it is stored in the BATCHID variable <b>before</b> the header is created.
    Any help, references, explanations greatly appreciated (and rewarded with points)
    BMV

    Hi Brian
    Here is the related part from the weblog of ABAP expert Horst Keller. Hope it may help. For the full document, you can visit <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.wcm.compound.docs/library/uuid/f1391fc3-0301-0010-d384-fccd036f1c67">here</a>.
    The values of all system fields in this table are implicitly set when the program is started, every time a screen layout of a screen is sent, and when the internal mode is set. The GET TIME command explicitly updates the system fields, except for sy-dayst, sy-fdayw and sy-tzone.
    With the exception of sy-datlo and sy-timlo, all system fields refer to the local date and time of the current SAP system. The ABAP runtime environment clock is synchronized with the database server clock at regular intervals in order to calculate the local time of the SAP system. During the synchronization process, the ABAP runtime environment clock is set to the database server clock. Because this happens on all application servers in an SAP system, the ABAP runtime environment clock is synchronous with the clocks on all other application servers and with the database system clock, and thus shows the local time of the entire SAP system. The time zone on which the local time of an SAP system is based is the only entry in the database table TTZCU.
    The content of sy-zonlo is taken from the user master record of the current user. The values of sy-datlo and sy-timlo are calculated from sy-datum and sy-uzeit and from the time zone of the SAP system for the time zone in sy-zonlo. If the user master record does not contain a time zone, or if it contains an invalid or an inactive time zone, sy-datlo and sy-timlo are set to the values of sy-datum and sy-uzeit. All valid time zones are defined in table TTZZ.
    Is't the naming of sy-datum and sy-uzeit really geeky?
    Time Stamps
    The above system fields for date and time are not sufficient for many requirements of determining unique points in time: They represent local times and the values are measured in seconds. For more exact date and time determination, you use time stamps.
    A time stamp represents date and time in the form YYYYMMDDHHMMSS. YYYY is the year, MM the month, DD the day, HH the hour, MM the minutes and SS the seconds. There is a short form and a long form. In the long form, the format specified above additionally contains 7 decimal places for fractions of seconds, which allows for an accuracy of up to 100 ns. The maximum time resolution depends on the operating system of the application server and may be less.
    A valid time stamp must contain values whose date and time specifications before the decimal separator correspond to valid values for the data types d and t. Time stamps in this form are always considered as UTC (Universal Time Coordinated, basis for calculating worldwide time specifications; the UTC reference time is based on Greenwich Mean Time, GMT, but is not a time zone; it has no daylight saving time or summer time) time stamps when processed with the corresponding statements. You use the statement GET TIME STAMP to create a time stamp that represents the current UTC reference time.
    Regards
    *--Serdar <a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=qbk%2bsag%2bjiw%3d">[ BC ]</a>

Maybe you are looking for

  • Can I use OSX Server instead of Dropbox?

    We are considering buying OSX Server.  One basis for the purchase would be to replace Dropbox.  We currently use Dropbox with local sync of folders, so all oru people work directly in folders that are synced to everyone else.  Thus all docs are avail

  • Download speeds awful on 4mb line

    Please can someone hear this out because it's driving me mad. I have two Macs, iMac G5 and iBook. I alos have a, dare I say it, a PC laptop. I am connected to the internet with Telewest Broadband (blueyonder) on a 4mb line. My download speeds on the

  • TS1367 Where is the power button on an iMac

    Screen is asleep. I hear computer running but can't get screen to come on. Where is power button?

  • Supported resolution different between OSX and XP

    Hey guys, I have a proview PL576Ws 15.4" widescreen connected to my macbook pro. It supports up to a 1280x800 resolution but only in Windows XP, when I try to get it to display 1280x800 in Mac OSX Leopard it claims "MODE NOT SUPPORTED" and fails to d

  • Search Woes!

    All, Right now my company wants a fast keyword searching methodology. All we want to keyword search is records from a single table. We wont be using outside files, anything, just VARCHAR2 columns. We need to be able to combine a keyword search query