Dates can be a bit of a challenge. This article explains three points:
- how to convert a record's date field value into a JavaScript Date object.
- how to add/subtract days to a JavaScript Date object.
- how to pass a JavaScript Date object to a record's date field value.
1. How to convert a record's date field value into a JavaScript Date object
var cardate = new Date (carRecord.vcar_DateMade);
Please read the article "Validation of Dates" which discusses the parsing rules that need to be followed to successfully create a date object.
2. How to add/subtract days to a JavaScript Date object
cardate.setDate(cardate.getDate() -14 );
3. How to pass a JavaScript Date object to a record's date field value
// myRecord is a communication record (already created) myRecord.Comm_ToDateTime = cardate.getVarDate() ;
That's it!! It's easy once you know!
External Link: