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

Show a message in EDC/CDMS when the date is more than X days before today or in the future

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

Table of Contents

Show a message if a year is in the future Show a message if years are not the same

If you want to give a message when the date is more than X days before today, or in the future, you can use this formula.


In this example 10 days or more are used as the limit.

 

You can enter your variable name between these brackets {Variablename}

 

var castorDate = moment('{Variablename}','DD-MM-YYYY');
var today = moment();
var tenDaysAgo = moment().subtract(10, 'days');
if(castorDate.diff(moment()) > 0 ){
 'This date is in the future';
} else {
 if(castorDate.diff(tenDaysAgo) > 0) {
 'This date is less than 10 days ago';
 } else {
 'This date is more than 10 days ago.';
 }
}

 

Show a message if a year is in the future

Use this calculation template if you would like to check whether the year is in the future and display a message

 

var castorYear = moment('{Variablename}').format('YYYY');
var todayYear = moment().format('YYYY');
if(castorYear > todayYear ){
 'This year is in the future';
} else {
 'This year is correct';
}

 

Test this template in the calculation helper.

 

Show a message if years are not the same

Use this calculation template to check if year variables entered are the same and display a message.

 

var year_1 = moment('{year1}', 'YYYY');
var year_2 = moment('{year2}', 'YYYY');
var diff = year_2.diff(year_1, 'y');
if (diff < 0) {
 'Error';
} else {
 'OK';
}

 

Test this template in the calculation helper. 

date notification date alert

Was this article helpful?

Yes
No
Give feedback about this article

Related Articles

  • Check if a date is before another date and show an error in EDC/CDMS if so
  • Using if/else logic with dates in EDC/CDMS
  • Doing date (and time) calculations in EDC/CDMS: the basics
  • Calculations with Number & Date Field
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