Calculations between two time fields

Hello

I have a form with a time for the start time field and a text field for the user to enter a duration (for example, 00:30:00).

There is another field for the end of time (which has a calculation script using the date and starting time fields).

The script that was placed in the end time field works except the script gives a negative result.

For example the start time field is 16:03:33 and 00:30:00 duration field calculation end is showing time field-

Please can someone advise how I can change the script of the time field end to show the correct result of 16:33 (without the negative)?


create string for the current date
var oToday = new Date();
sToday var = util.printd ("yyyy/mm/dd", oToday);

get the value of the start time field

var sStart = this.getField("Action_Start_Time").value;

create the JavaScript date object time for start time
var start = util.scand ("yyyy/mm/dd hh: mm:", sToday + sStart);


get the duration value

Send var = this.getField("Action_Time").value;

create a JavaScript date object time to end time
oEnd var = util.scand ("yyyy/mm/dd hh: mm", sToday + shipment);

calculate the difference in hours, the difference in hours
var DiffHours = (oEnd.valueOf () - oStart.valueOf (()) / 1000 / 60 / 60;
Event.Value = Math.floor (DiffHours) + ': ' + util.printf ("%,302.0f", (((DiffHours % 1) * 60) .toFixed (()));

Any help will be greatly appreciated.

You cannot change the '-' operator operator '+' being Modulo calculation date and time calculations. You must calculate the different parts of the date and time of the start time and elapsed time and then convert these values into a date object time and format of this new date time object.

Clear the field
Event.Value = "";
getting the activity start time
var sEventStart = this.getField("Activity_Start_Time").value;
calculate only if there is a start time
If (sEventStart! = "") {}
operations of the console are for debugging and illustration
/*
Console.Show ();
Console.clear();
*/
convert a date object change if necessary format
var oEventStart = util.scand ("YYYY, mm, DD, HH", nNowYear + "," + (nNowMonth + 1) + ',' + nNowDate + ', ' + sEventStart);
Console.println ("oEventStart:" + oEventStart);

get the date current time
var oNow = new Date();
Console.println ("oNow:" + oNow);
get the date parts
var nNowYear = oNow.getFullYear ();
var nNowMonth = oNow.getMonth ();
var nNowDate = oNow.getDate ();
/*
Console.println ("nNowYear:" + nNowYear);
Console.println ("nNowMonth:" + nNowMonth);
Console.println ("nNowDate:" + nNowDate);
*/
get the duration of activity
var sEventDuration = this.getField('Event_Duration').value;
If no entry in force at time zero
if(sEventDuration == '') sEventDuration = "00:00:00 ';
convert the time in hours and minutes
var aEventDuration = sEventDuration.split(":");
/*
Console.println (' hours - aEventDuration [0]: "+ aEventDuration [0]");
Console.println ('Minutes - aEventDuration [1]: "+ aEventDuration [1]");
Console.println (' hours start: "+ oEventStart.getHours ());
Console.println ("minutes:" + oEventStart.getMinutes ());
Console.println ("second Start:" + oEventStart.getSeconds ());
*/
calculate the minutes and the end times
var nEndHour = Number (oEventStart.getHours ()) + Number(aEventDuration[0]);
var nEndMinute = Number (oEventStart.getMinutes ()) + Number(aEventDuration[1]);
if(aEventDuration.Length == 3)
var nEndSecond = Number (oEventStart.getSeconds ()) + Number(aEventDuration[2]);
on the other
var nEndSecond = Number (oEventStart.getSeconds () + 0;
/*
Console.println ("nEndHour:" + nEndHour);
Console.println ("nEndMinute:" + nEndMinute);
Console.println ("nEndSecond:" + nEndSecond);
Console.println ("nNowYear:" + nNowYear);
Console.println ("nNowMonth:" + nNowMonth);
Console.println ("nNowDate:" + nNowDate);
*/
do the date for the end of the event object - calculate the hours and minutes
oEnd var = new Date (nNowYear, nNowMonth, nNowDate, nEndHour, nEndMinute, nEndSecond);
Console.println ('oEnd: ' + oEnd);
change the format if necessary
Event.Value = util.printd ("HH", oEnd);
} / / end of event time

Tags: Acrobat

Similar Questions

  • Formula of FormCalc to make the difference between two time fields if they are populated - help please


    Hello

    I have a laptop (TotalTime1) which refers to two other cells in the updated hour-shaped (Start1 and 1 to finish).

    The formula below is intended to make the difference between the time of departure and of arrival if they are populated.

    I had to work unconditionally HasValue, but the formula was calculated when there is no value in the Start1 and Finish1 (due to the time format).

    This is the code I have, it is said that there is an error of almost the last line; I'm sorry if I'm posting this in the wrong way, I haven't posted on this forum before but this is:

    If (HasValue (Finish1) and HasValue (Start1)) then if (Time2Num (Start1.formattedValue, "HH: mm") < Time2Num (Finish1.formattedValue, "Hh: mm")) then Abs (Time2Num (Start1.formattedValue, "HH: mm")-Time2Num (Finish1.formattedValue, "HH: mm")) / (60 * 60 * 1000) another 24 - ABS (Time2Num (Finish1.formattedValue, "HH: mm")-Time2Num (Start1.formattedValue, "HH: mm")) / (60 * 60 * 1000) endif

    Any help would be appreciated.

    Cordially Fetachini

    you need an another endif at the end (you have nested statement and only 1 endif)

  • Calculate elapsed hours between two time fields

    I have a form with fields TimeStart and TimeEnd. Both are formatted as field time in the format hh: mm tt. I also have a field called hours with the number format. Here is the Javascript code that I have in the section calculation Script custom field hours. Could someone tell me why it doesn't work? This script started as a date calculation script (work), and I changed to the calculation of hours instead of days.

    var strStart = this.getField("TimeStart").value;

    var strEnd = this.getField("TimeEnd").value;

    If (strStart.length & & strEnd.length)

    {

    var timeStart = util.scand ("h: mm tt", strStart);

    var timeEnd = util.scand ("h: mm tt", strEnd);

    diff var = timeEnd.getTime () - timeStart.getTime ();

    var hour = 60 * 60 * 1000;

    var h = Math.floor (diff/oneHour);

    Event.Value = hours;

    }

    of another event.value = 0;

    The order for the calculation of the fields is wrong, you need to update.

  • Difference between two times

    I am building a working method in LiveCycle, and I want to track how long the procedure takes. To do this, I have two time fields, and then a third time field to find the difference between two time fields. Looking at other posts to discussion, I could find a Javascript code that was part of what I wanted, but I can't get the third time field to display in the format I want. I tried to change the habits of the fields and that did not work. Could someone offer some advice on how to change the format or help me with the code?  I couldn't figure to attach the actual file, but I have attached a picture of the PDF file and the Javascript code I used.  If you look at the TimeIn (hh: mm) and time (hh: mm) areas (on the photo, I have attached), you will notice that the TotalTime comes out like HMM, and I want that it out as hh: mm.

    Adobe Time Difference Example.jpg

    Javascript Time Difference Code.jpg

    Any help would be greatly appreciated!

    Thank you

    this.rawValue = (totalHrs > 9? String (totalHrs): '0' + String (totalHrs)) + ':' + (totalMins > 9? String (totalMins): '0' + String (totalMins));

  • calculation of time between two time as timestamp

    How can calculate two hour, START as the timestamp TIME in the data type, END TIME as of time also.

    select END_TIME-START_TIME from PROG_DLY_WORK
    

    Result

    + 01:50:00.000000 000000000

    How can get exactly the time spent as 01:50 ? and these calculated time must sum (elapsed_time) in another column.

    oracle as PaaS cloud environment

    Product VERSION STATUS
    NLSRTL11.2.0.3.0Production
    Oracle Database 11g Enterprise Edition11.2.0.3.064 bit Production
    PL/SQL11.2.0.3.0Production
    AMT for Linux:11.2.0.3.0Production

    Time difference between two columns in hours

    Start

    FOR REC IN (SELECT START_TIME, END_TIME, CALC_TIME CAL_ID)

    LOOP

    UPDATE CALc_TIME

    SET ELAPSED_TIME = round (())

    TO_DATE (to_char (REC. End_time, 'ddmmyyyyhh24miss'),

    "ddmmyyyyhh24miss")-

    TO_DATE (to_char (REC. Start_time, 'ddmmyyyyhh24miss'),

    "ddmmyyyyhh24miss")

    () * 24).

    WHERE CAL_ID = REC. CAL_ID;

    END LOOP;

    end;

    Lag in minutes

    Start

    FOR REC IN (SELECT START_TIME, END_TIME, CALC_TIME CAL_ID)

    LOOP

    UPDATE CALc_TIME

    SET ELAPSED_TIME = round (())

    TO_DATE (to_char (REC. End_time, 'ddmmyyyyhh24miss'),

    "ddmmyyyyhh24miss")-

    TO_DATE (to_char (REC. Start_time, 'ddmmyyyyhh24miss'),

    "ddmmyyyyhh24miss")

    () * 24 * 60)

    WHERE CAL_ID = REC. CAL_ID;

    END LOOP;

    end;

  • How to find the hours between two times

    Hai All

    I had a problem I need to calculate work time

    For example

    Respondent outtime

    0815 1715

    So I need to calculate a time between these two times

    How can I do using function for 100 our

    Concerning

    Srikkanth.M

    Hello

    use the below the update statement.

    update dail_att set wtime =  extract(hour from (to_date(outtime,'HH24:MI')-to_date(intime,'HH24MI')) day to second);
    

    Solution of the sample...

    PRAZY@11gR1> desc dte;
     Name            Null?    Type
     ------------------- -------- --------
     INTIME           VARCHAR2(4)
     OUTTIME        VARCHAR2(4)
     HRS                NUMBER
    
    PRAZY@11gR1> select * from dte;
    
    INTIME     OUTTIME           HRS
    ---------- ---------- ----------
    0815       1715
    0900       1800
    0830       1630
    
    Elapsed: 00:00:00.00
    PRAZY@11gR1> update dte set hrs = extract(hour from(to_date(outtime,'HH24MI')-to_date(intime,'HH24MI')) day to second);
    
    3 rows updated.
    
    Elapsed: 00:00:00.01
    PRAZY@11gR1> select * from dte;
    
    INTIME     OUTTIME           HRS
    ---------- ---------- ----------
    0815       1715                9
    0900       1800                9
    0830       1630                8
    
    Elapsed: 00:00:00.00
    

    Kind regards
    Prazy

    Published by: Prazy on March 24, 2010 12:43

  • Week, month, quarter and year calculation between two days with a quantity?

    I have a problem that I can't solve.

    Users enter a forecast (quantity) and a validity period between two dates.
    Expected quantity is always a monthly forecast.

    The problem is that the user wants to see the forecast by week, month, quarter and year.


    Material |     Quantity |     Date_from | Date_to
    Label45 |     1500 |     2009-09-01 | 2009-12-31


    How can I easily calculate the amount so that the user can enter e.g. week 2009.41 and see the forecast this week?

    You should test for your specific environment, but I would be very surprised if a function has surpassed SQL directly.

  • difference in hours between two time zones of differnet

    I have a sysdate (EAST) and a function util_pkg.local_tz returns a different datetime value.
    I need to get the difference in hours between sysdate and another date.

    Select sysdate, util_pkg.local_tz (sysdate, ' Asia/Seoul') of double;

    18/05/2011 11:15:00.000000000 FROM 18/05/2011 10:15 PM + 09:00

    Quest:-find the difference in hours between these two date and then add the difference of hours + sysdate

    FUNCTION local_tz (p_datetime IN TIMESTAMP,
                          p_timezone IN VARCHAR2)
          RETURN TIMESTAMP WITH TIME ZONE
       AS
       BEGIN
          RETURN FROM_TZ(p_datetime, TZ_OFFSET(con_database_timezone))
                         AT TIME ZONE TZ_OFFSET(p_timezone);
       END local_tz;

    When you calculate the diff between TIMESTAMP WITH TZ they both are converted to time UTC (in fact they are stored as UTC). So diff between SYSTIMESTAMP in EST and SYSTIMESTAMP in Seoul will always be 0, as bioth are "now". You need to cast TIMESTAMP WITH TZ 'losing' time zone timestamp:

    SQL> select cast(systimestamp at time zone 'Asia/Seoul' as timestamp) - systimestamp from dual;
    
    CAST(SYSTIMESTAMPATTIMEZONE'ASIA/SEOUL'ASTIMESTAMP)-SYSTIMESTAMP
    ---------------------------------------------------------------------------
    +000000000 13:00:00.000000
    
    SQL>  
    

    SY.

  • How to calculate the difference between two times by the NUMBERS

    I'm so bothered by the fact that I can't understand that.

    Cell B2 - 08:00

    Cell C2 - 10:50

    (How can cell D2 - I get this cell to calculate the difference and say 02:50?)

    I know it's probably one of the most basic operations, but for the life of me I can't understand it. The cells B2 and C2 are formatted for a 24-hour clock. But if I tell the system to just subtract the two, I get "0,118. Everything I find on the forum search goes beyond what I need. Can someone help me?

    Thank you

    Hi sapirs,

    Departure and arrival of the cells are in Date and time with Date format: no and time: 24-hour clock.

    Formula in D2 (fill down)

    = C2−B2

    The results become a duration format, but under automatic (numbers automatically worth this format)

    If you wish, you can change the cells of lasting results.

    What Data Format have your result cells?

    Kind regards

    Ian.

  • calculations between two values of the sequential loop iterations

    Hi all

    I have a code that came out our power (DSP) of a FFT spectral density. An input frequency and then intervened at a value of input from the user. I would like to know the difference of the PSD between each stage of the frequency. Attached, that's what I would get. To avoid confusion, I don't want to produce a file that looks like this. I want just the column 'delta' as an indicator on the front panel, so I can control my change in PSD. I don't need the entire table, just the delta between the current iteration and the previous iteration. I tried to use a loop with shift registers, but I'm not sure where to go to from there. I thought that, since the shift registers sends the data of loop to loop, that I could output the value before it went into the next iteration, but I don't have a chance. Any help is appreciated. Unfortunately, I am unable to put the code due to the policy of the company. I know it makes things much more difficult.

    Thank you.

    Suggestions do not seem quite right, but I found a way to do it. Attached, is the way that I did.

  • calculation between two columns that depends on the minimum value

    I have the table with the following values, how can auto calculation based to a minimum value to assign each line then?

    Seq 1 reference ID price price of the difference % of difference
    131500
    233500
    334000


    calculation logic

    SCREEN.png


    the result should be...

    Seq 1 reference ID price price of the difference % of difference
    13150000
    23350020001.333
    33400025001,666

    Dev environment

    service of Cloud Computing by oracle

    PRODUCT VERSION STATUS
    NLSRTL11.2.0.3.0Production
    Oracle Database 11g Enterprise Edition11.2.0.3.064 bit Production
    PL/SQL11.2.0.3.0Production
    AMT for Linux:11.2.0.3.0Production

    with

    a_table as

    (select 1 seq_1, 3 ref_id, 1500 Union double all the)

    Select 2,3,3500 from all the double union

    Select double 3,3,4000

    )

    Select seq_1, ref_id, price,

    price - min (price) on differece_price (partition by ref_id by seq_1 order),

    price / min (price) over (partition by seq_1 order ref_id) - 1 difference_percent

    of a_table

    SEQ_1 REF_ID PRICE DIFFERECE_PRICE DIFFERENCE_PERCENT
    1 3 1500 0 0
    2 3 3500 2000 1.33333333333333333333333333333333333333
    3 3 4000 2500 1.66666666666666666666666666666666666667

    Concerning

    Etbin

  • HOW TO USE BETWEEN TWO TIMES

    CREATE TABLE HH (HELLO NUMBER (10));

    DATA TABLE 1,2,3,4,5,6 HH... 30

    NOTE: NOT USED UNIOUN FUNCTION

    NEED TO OUTPUT
    -------------
    DISPLAYED 10 > = HELLO AND HELLO < = 15 AND
    20 > = HELLO AND HELLO < = 25


    PLEASE GIVE ME THE QUREY





    I AM USNIG THIS QUERY-> NO RESULTS COME
    -----------------------
    SELECT * HELLO WHERE BETWEEN 10 AND 15 HH
    AND HELLO BETWEEN 20 AND 25

    Please do not write in all caps: this is considered a bad practice in a forum.

    You use OR instead of AND:

    select * from hh
    where hello between 10 and 15 or hello between 20 and 25;
    
  • Problem with difference of calculation between two dates from Monday to Saturday

    Hello

    I need help to change a function return number you dates, including Saturday hours (09:00 - 14:00), Monday to Friday (09:00 - 21:00);

    This is my code;

    CREATE OR REPLACE
    FUNCTION TEST2 (FECHA_INICIO DATE, DATE FECHA_FIN)

    RETURN NUMBER IS THE NUMBER OF HORASTOTALES;
    date the date;

    BEGIN
    If)
    SELECT date, to_char (date, 'DY', 'NLS_DATE_LANGUAGE = ENGLISH') dia.
    (SELECT to_date('FECHA_INICIO') + LEVEL - 1 date
    OF THE DOUBLE
    CONNECT BY LEVEL < = (FECHA_FIN - FECHA_INICIO))
    WHERE TO_CHAR (DATE, 'DY', 'NLS_DATE_LANGUAGE = ENGLISH') not IN ("SAT") THEN

    with t as)

    SELECT CASE LEVEL
    When 1 then greatest (fecha_inicio, trunc (fecha_inicio) + 9 / 24)
    to another level - 15 + trunc (fecha_inicio) / 24
    end fecha_inicio
    case connect_by_isleaf
    When 1 then least (fecha_fin, trunc (fecha_fin) + 21 / 24)
    Another trunc (fecha_inicio) + level - 3 / 24
    end fecha_fin
    of the double

    connect by level < = trunc (fecha_fin) - trunc (fecha_inicio) + 1).

    Select sum (more large (fecha_fin - fecha_inicio, 0)) * 24 horas
    in horastotales
    T

    WHEN TRUNC (FECHA_INICIO) - TRUNC (FECHA_INICIO, 'iw') < 5;

    RETURN HORASTOTALES;

    ) ELSE IF
    Return HORASTOTALES + 5;
    END;

    concerning

    Hello again,

    Using this function, which makes me ask properly, what hours, my problem is that I can not include Saturday hours;

    create or replace FUNCTION TEST (FECHA_INICIO DATE, FECHA_FIN DATE

    )

    RETURNS the NUMBER IS horastotales NUMBER;

    BEGIN

    with t as)

    SELECT CASE LEVEL

    When 1 then greatest (fecha_inicio, trunc (fecha_inicio) + 9 / 24)

    to another level - 15 + trunc (fecha_inicio) / 24

    end fecha_inicio

    case connect_by_isleaf

    When 1 then least (fecha_fin, trunc (fecha_fin) + 21 / 24)

    Another trunc (fecha_inicio) + level - 3 / 24

    end fecha_fin

    of the double

    connect by level<= trunc(fecha_fin)="" -="" trunc(fecha_inicio)="" +="">

    )

    Select sum (more large (fecha_fin - fecha_inicio, 0)) * 24 horas

    in horastotales

    T

    When TRUNC (FECHA_INICIO) - TRUNC (FECHA_INICIO, 'iw')<>

    RETURN horastotales;

    END;

    Example:

    SELECT TEST (TO_DATE (January 7, 2013 09:10 ',' DD-MM-YYYY HH24 '), TO_DATE (February 7, 2013 09:00 "," DD-MM-YYYY HH24 ')) horas

    OF THE DOUBLE

    output: 11, 8 hours

    Then try to add parts of your function, to get what I want, but it gives me compilation errors

  • Time sheet calculation of time fields (TimeIN + TimeOUT) - (BreakIN + BreakOUT)

    Hello


    I'm really a novice in the field of pdf script, I would like to ask if someone could help me make a calculation script of a time field with a TOTAL production WORKED HOURS in a day to a calculation of

    (TimeIN + TimeOUT) - (TimeBreakIN + TimeBreakOUT)

    still other topics that the TimeIN, timeout, the TimeBreakIN or the TimeBreakOUT can also run through midnight

    I'm looking for other forums, but not found anything that could match my needs.

    Time at: 17:00

    TimeBreakIN: 20:00

    TimeBreakOUT: 21:00

    OUT time: 02:30

    the script that I expected to be in the

    TOTAL HOURS WORKED is: 8.50 (or 08:30)

    I will be also repopulate this script to each row/day until I add in 1 pay as a TOTAL period

    Thanks in advance to those who can help me.

    Hi JunPapay,

    You may want to take a look at this: calculations between two time fields

    Thank you

    Abhishek

  • Date/time field calculation

    Hi Experts,

    Our requirement is in the Service request object when one of the values from the drop-down list is changed into announcements, then the column date deadline must fill in with the value of the 4 hours added to the current date/time date/time.

    How to get there. Therefore, I see no function to perform calculations on date/time fields.

    Immediate response is appreciated.

    Thank you and best regards,
    Lemu

    Hello
    You will need to create a WF for this.
    Name of WF: Change status
    Raises the event: before save modified record
    Record Service of Type request:

    In Action of WF
    Name: Update Date
    Type: field update
    Field name: Your domain name
    value: Timestamp() + Duration ('P0Y0DT4H')

    It's your problem.

Maybe you are looking for

  • I don't have a menu icon on my page. w

    that was a very good product is useless when you can't check addons

  • background?... my computer won't let me have a wallpaper, only colors... Please help!

    I can't post a background for my desktop, my computer doesn't even gives me the option, I can only choose solid colors that come with all of the other computers... but I can have a screen saver and change my themes, just not a background... someone a

  • E-mail application

    Hello I'm doing a simillar e-mail request to whatsapp. My first approach is a listfield with an inputtextfield on the bottom. For that, I am on the field of text with setStatus. I am facing problems: -Have the inputtextfield worn when the screen disp

  • Sample Web service

    Hi all I have searched many sites to something simple to access the webservice in blackberry but couldn't find a solution. Almost all examples follow JDE environment that is not so in my case. some sites that I searched recently are: ( http://www.bla

  • Can we run traceroute of sourcefire defense center

    Hoe do run us a trace of the DC for the sensor, and vice versa. I'm going to DC 3500 and sensor series 1000 and 7000 and 8000 3d.