Skip to Main Content

Java and JavaScript in the Database

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Subtract two dates in JavaScript

CometMay 11 2017 — edited May 13 2017

I am developing an application in Apex 5.  On a page I placed a tabular form. The tabular form has a from-date field and a to-date field.  I want to create a computed column on the form which is the difference in hours between the from and to dates. I have a JavaScript function which will display a computed  column on the tabular form as follows:

function f_calculate_total(pThis) {

  var logged = 0;

  var row_id  = pThis.id.substr(4);

  var start_time = $('#f09_'+row_id).val();

  var end_time = $('#f11_'+row_id).val();

  logged = 24*(0.16); 

$('#f13_'+row_id).val(logged);

The names of the dependent columns are computed column f13, from-date f09, and to-date f11.

The from date and to-date both have the element attributes property set to:

onchange="f_calculate_total(this);"

The function works and displays the computed value of the variable named logged.

My question is, what is the JavaScript to compute the difference between the date-times end_time minus start_time?

Thank you

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 10 2017
Added on May 11 2017
1 comment
1,259 views