Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Contact Us
  • Home
  • CDMS
  • Castor CDMS Calculations Manual
  • Date and time difference templates

Calculate time difference in hh:mm:ss (using text fields): EDC/CDMS

Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • CDMS
    Castor CDMS Manual Castor CDMS Calculations Manual Frequently Asked Questions Articles for Data Managers Castor CDMS Compliance Release Documents
  • eConsent
    Castor eConsent Manual Castor eConsent Compliance Release Documents
  • SMS
    Castor SMS Manual Castor SMS Compliance Release Documents
  • Castor Connect
    Castor Connect Compliance Release Documents Castor Connect Manual Castor Connect - Participant Quick Start Guide
  • Helpdesk
    News Other Resources Castor products knowledge resources
  • Status page
  • Completing a Study
+ More

Time fields in Castor only capture hours and minutes. If you would like to capture time in the format hh:mm:ss, you will need to use text fields. However, you can calculate with those as well.

To calculate the difference in time between two text fields that use hh:mm:ss, you can use the following template. The output will give the time difference in hh:mm:ss.

var timePoint_1 = '{text1}';
var timePoint_2 = '{text2}';
var split_1 = timePoint_1.split(':');
var split_2 = timePoint_2.split(':');
var date1 = new Date(0, 0, 0, split_1[0], split_1[1], split_1[2]);
var date2 = new Date(0, 0, 0, split_2[0], split_2[1], split_2[2]);
var timeDifference = new Date(date2 - date1);
var diff = Math.floor(timeDifference/1000);
var hours = Math.floor(diff/3600);
var minutes = Math.floor((diff-(hours*3600))/60);
var seconds = diff-(hours*3600)-(minutes*60);
if(hours < 10){
 hours = "0" + hours;
}
if(minutes < 10){
 minutes = "0" + minutes;
}
if(seconds < 10){
 seconds = "0" + seconds;
}
hours + ":" + minutes + ":" + seconds;

Replace text1 and text2 with your own variables


text input time calculation

Was this article helpful?

Yes
No
Give feedback about this article

Related Articles

  • Calculate time difference between two time fields: EDC/CDMS
  • Calculate the age using a date variable: EDC/CDMS
  • Calculate the difference between two dates: EDC/CDMS
  • Check if the difference between two dates is between limits: EDC/CDMS
ISO 27001
FDA - 21 CFR part 11
ICH GCP compliant
HIPAA compliant
CDISC
ISO 9001
gdpr compliant

Products & Industries

  • Electronic Data Capture (EDC)
  • ePRO
  • eConsent
  • Decentralized Clinical Trials (DCT)
  • Clinical Data Management
  • Medical Device & Diagnostics
  • Biotech & Pharma
  • CROs
  • Academic Research

Resources

  • Thought Leadership
  • Blog
  • Castor Academy
  • Knowledge Base

 

Company

  • About Us
  • Careers
  • News
  • Contact Support
  • Contact Us

Legal & Compliance

  • Terms of Use
  • Privacy & Cookie Statement
  • Responsible Disclosure Policy
  • Good Clinical Practice (GCP)
  • ISO Compliance Certificates
  • GDPR & HIPAA Compliance
  • Security Statement

© 2022, Castor. All Rights Reserved.

Follow us on social media


Knowledge Base Software powered by Helpjuice

Definition by Author

0
0
Expand