[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).

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

  • Date time field problem

    Hello there
    This maybe a simple problem but on the Date time field object i have input a display pattern and put the error message in. When I preview the PDF and populate the object with random text the pop up box will display my error message.
    What it does not do is clear the text I have input so the date can be re-entered correctly, which is what I was expecting. Therefore the user can continue on without addressing the date correctly.
    Can anyone advise what I should do to get this to work?
    Thanks
    Darren

    Hi
    The first time I thinkanyone has answered their own post. So for the benefit of anyone else I added the folowing script to the exit event
    of the date field object
    if (page.subform.dateobject.rawValue == page.subform.dateobject.formattedValue) {
    xfa.host.resetData("xfa.form.Formtitle.Page.subform.datefieldobject")
    Not sure why it works but just played around with it.

  • 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

  • Time Machine - Date & Time format problem

    I'm sorry if this has been mentioned elsewhere, but I was unable to find it. Following a change I made to the Date & Time prefs in order for the complete date to show in the menu bar I am now unable to determine the time a backup was made or anything else for that matter.
    I made the modification via the International Preferences - Formats pane, but this did not display as I wanted and I have since gone back to how it was originally or so I thought! Now all the time stamps are showing as a five or six digit number. Does anyone know have to change this back!
    thanks
    littlebad

    littlebad wrote:
    I'm sorry if this has been mentioned elsewhere, but I was unable to find it. Following a change I made to the Date & Time prefs in order for the complete date to show in the menu bar I am now unable to determine the time a backup was made or anything else for that matter.
    I made the modification via the International Preferences - Formats pane, but this did not display as I wanted and I have since gone back to how it was originally or so I thought! Now all the time stamps are showing as a five or six digit number. Does anyone know have to change this back!
    Hi, and welcome to the forums.
    Do you mean in the TM Interface +(Enter Time Machine)?+
    If so, try turning TM off, selecting the "none" drive, quitting System Preferences, then going back and re-selecting the drive.
    If that doesn't work, try a "full reset:"
    Turn TM Off, de-select the drive, note any exclusions in Options, quit System Preferences.
    Delete the file /Library/Preferences/com.apple.TimeMachine.plist (in your top-level Library folder, not your home folder).
    Re-select your drive (and re-enter any exclusions).
    Do a +Back Up Now+ or wait for the next scheduled backup.

  • Date Difference Calculation problem

    I am creating a form which should calculate the number of days between two calender dat
    es using the Date2Sum expression but my result cell gives me
    zeo despite setting the locale and the calculation correcttly. Where could
    my problem be?
    Darlington Sakwa

    Validate the date patterns on the date fields match the date patterns used in Date2Num. For example, the attached has a start date with the display date pattern date{YYYY-MM-DD} and that matches the date pattern in my Date2Num function call.
    // form1.page1.startDateNum::calculate - (FormCalc, client)
    if (form1.page1.startDate.isNull) then
      $.rawValue = ""
    else
      $.rawValue = Date2Num(form1.page1.startDate.rawValue,"YYYY-MM-DD")
    endif
    Steve

  • Time calculation problem

    after loading and transforming dates tot the ISO8601 format, i need to extract a start and ending time of a interval.
    The time is 02-04-2007T10:30:00Z and is the end of the interval, which function can i use to calculate the beginningtime? Each interval is a period of 5 minutes.

    If you were loading the data into a DATE column in the past, I suspect that the time was not "disappeared". You probably just weren't asking it to be displayed when you queried the data.
    Oracle stores DATE data in a packed binary format. This is independent of the format of the data that was inserted or the format of the data that is displayed and always contains a date and time component.
    When you query that data, the front end application has to convert the date to an appropriate string. If you have particular formatting needs (i.e. ISO 8601), you would normally write a function, i.e. to_iso_8601, that takes a DATE and returns a VARCHAR2 in ISO 8601 format and call that on the display edge. You would store data in the database as a DATE and convert it to a string at the last possible moment before displaying it.
    Justin

  • 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

  • Activating Master data time out problem

    Dear all,
    when i try to activate master data, it gives error message "time out" . in which tcode i can increase tha time out duration?
    Thanks

    Hi John,
    Please check the thread below:
    Activate time-dep. master data (0EMPLOYEE)
    This also  suggests to run the master data activation program in background, This will solve your issue,
    -Vikram

  • 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);
    }

  • Date/Time Problem Results In Spinning Wheel

    My mom's eMac recently was shutdown during a power outage, and came back with the date/time reset problem (I'm familiar with this when my battery comes loose on my iBook).
    Only problem is, if I try to launch System Preference or Open Date & Time I get the spinning wheel that doesn't allow me to reset the date/time. On top of that, I can't seem to get anything to launch right now b/c it seems Finder is what's getting the spinning wheel. The only thing that launches is AIM (which is on autolaunch), but it can't be accessed at all from the computer (though it does show up as signed on when I'm signed on to AIM at work).
    I've tried a force quit to relaunch finder with no results, and have also blasted the PRAM and tried the instructions for resetting the PMU (if I'm doing that right).
    One thing I can across is the possibility I need to replace the internal backup battery. Could that be the problem, or have I run into soemthing much more serious.
    Any help would be appreciated.

    Hello! A power outage often damages the disk's directory information. Boot from the install disc ("c" key down at startup with disc inserted) and right after the language screen navigate through the drop down menus to the disk utility and repair the disc. Run the repair multiple times if it reports errors until it doesn't report errors. Tom

  • 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

  • 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

  • Problem with Date/Time field in Adobe LiveCycle

    I am trying to create a form that has a check-in and check-out dates. I want the user to enter those dates and then have the form automatically compute how many nights the user intends on staying.
    I have two fields, CHECKIN and CHECKOUT, set up as text fields. My third field, NIGHTS, has the following script to do the calculation:
    var strStart = CHECKIN.rawValue
    var strEnd = CHECKOUT.rawValue
    if(strStart.length && strEnd.length)
    var dateStart = util.scand("mmm d, yyyy",strStart);
    var dateEnd = util.scand("mmm d, yyyy",strEnd);
    var diff = dateEnd.getTime() - dateStart.getTime();
    var oneDay = 24 * 60 * 60 * 1000;
    var days = Math.floor(diff/oneDay);
    this.rawValue = days;
    else
    this.rawValue = 0;
    NOW...this is fine if the user inputs a four-digit year. If not, it's trouble. SO, what I want to do is change the CHECKIN and CHECKOUT fields to the date/time field so they select the date off the pop-up calendar.
    When I make the changes, I can't get the script to work for the NIGHTS field.
    CAN ANYONE HELP THIS NEWBIE?

    Make sure the format of the date strings provided by the calendar is what you are expecting. Or use the "formattedValue" for the input strings.

  • 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

Maybe you are looking for