Date Formatting in Aras

Hoping someone can help me with this weird issue I am having.

I have an item type that has a property defined h_attain_date and it's data type is date with no pattern defined.  I retrieve the data for this from our ERP system using a web service that returns a data set and I apply the value of the attain date to the property. The content of the date field in the data set is:

5/31/2017 12:00:00 AM

and the code that outputs this to the debug file I'm using is 

CCO.Utilities.WriteDebug("Project Update", Convert.ToString(partRow[p].h_attain_date));

I associate the value to the property using 

updItem.setProperty("h_attain_date", Convert.ToString(partRow[p].h_attain_date));

This all works fine and I see the data in the application as 5/31/2017.

Now comes the oddity.  I have another date property on another item date and the property name is h_due_date and again has no pattern defined.  I also use a web service with a data set to retrieve this data from our ERP system and I want to apply that value to the property.

The content of the date field in the data set is:

4/2/2019 12:00:00 AM

and the code that outputs this to the debug file I'm using is 

CCO.Utilities.WriteDebug("Project Update", Convert.ToString(po_row[r].h_due_date));

I associate the value to the property using 

addPO.setProperty("h_due_date", Convert.ToString(po_row[r].h_due_date));

When I run this piece of code, I get the error:

The specified value for property Due Date '4/2/2019 12:00:00 AM' of <item type> does not match the required format.

This is where it gets confusing for me, as the definitions are exactly the same, the code used to display the value returned from the web service is exactly the same with the exception of the field name, and the assignment of the property is done exactly the same way.

Anyone shed any light on this possibly??

  • Thanks to Aras Support for the answer for the above, I needed to add a couple of elements into the mix - here is the solution for anyone that might run into the same issue:

    var cntx = this.getInnovator().getI18NSessionContext(); 

    var dd_neutral = cntx.ConvertToNeutral(poRow[r].h_due_date, "date", "");

    addItem.setProperty("h_due_date", dd_neutral);