Created
April 4, 2018 17:16
-
-
Save DynCon365/64c47edef24d9c4207d8a305a0b7efce to your computer and use it in GitHub Desktop.
Dynamics 365/CRM | Get the value of a Date field (01/31/2018 or 31/01/2018)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get the value of the Opportunity Est. Close Date | |
var date = Xrm.Page.data.entity.attributes.get("estimatedclosedate").getValue(); | |
if (date != null) { | |
var day = date.getDate(); | |
var month = date.getMonth(); | |
var year = date.getFullYear(); | |
month++; | |
// Add leading 0's to single digit days and months | |
if (day < 10) {day = "0" + day;} | |
if (month < 10) {month = "0" + month;} | |
// Create a variable with the formatted date as MM/DD/YYYY | |
var formattedDate = month + "/" + day + "/" + year; | |
// Create a variable with the formatted date as DD/MM/YYYY | |
//var formattedDate = date + "/" + month + "/" + year; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment