Text Scroll

You must welcome, Thank you for visiting my blog.

Search This Blog

Sunday, June 28, 2020

Add/Subtract date, Month and Year in MS CRM


var Date1 = Xrm.Page.getAttribute(“date1”).getValue(); // retriving Date time valie of Date1 field

var newdate = new Date(
Date1.getFullYear(), // If you want to add Years please add number of Years by adding “+” symbol. 
Date1.getMonth(), // If you want to add Months please add number of Months by adding “+” symbol. 
Date1.getDate() + 10, // If you want to add Days please add number of days by adding “+” symbol.  In my code I have added 10 days to Date1 field.
Date1.getHours(), // If you want to add Hours please add number of hours by adding “+” symbol. 
Date1.getMinutes()); // If you want to add Minutes please add number of Minutes by adding “+” symbol.

Xrm.Page.getAttribute(“date2”).setValue(newdate); //Setting new Data time(after adding Days/Months/Years) to date2 field.

No comments:

Post a Comment