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
  • Calculations with date and time

Add hours and minutes to a datetime field in 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

If you want to add hours and minutes to a date & time field, you can use this template.

For this calculation, you will need a date & time field and a time field which are called 'datetime' and 'add_time' in this calculation.

 

//Set datetime into right format to add hours and minutes
var splitted_datetime = '{datetime}'.split(';');
var splitted_old_date = splitted_datetime[0].split('-');
var old_date = splitted_old_date[2] + '-' + splitted_old_date[1] + '-' + splitted_old_date[0];
var old_datetime = old_date + ' ' + splitted_datetime[1];
var datetime_dateobj = new Date(old_datetime);
//Split hours and minutes
var hours = '{add_time}'.split(':')[0];
var minutes= '{add_time}'.split(':')[1];
//Add hours and minutes and return in right format
var addHours = moment(datetime_dateobj).add(hours, 'hours');
new_datetime = addHours.add(minutes, 'minutes').format('DD-MM-YYYY HH:mm');
new_datetime;
time manipulation enhance time

Was this article helpful?

Yes
No
Give feedback about this article

Related Articles

  • Using if/else logic with dates in EDC/CDMS
  • Check if a date is before another date and show an error in EDC/CDMS if so
  • Show a message in EDC/CDMS when the date is more than X days before today or in the future
  • Doing date (and time) calculations in EDC/CDMS: the basics
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