Putting a DateTime value in a CrmDateTime field


When you want to assign a DateTime value to a CrmDateTime field while using the Webservice API it is not as simple as converting the DateTime field to a string and assigning the value.

The string has to be in a specific format.

Example:
CrmDateTime sEndDate = new CrmDateTime(MyDateTimeValue.ToString());

The above will NOT work.
Format the DateTime with the following format.

CrmDateTime sEndDate = new CrmDateTime(MyDateTimeValue.ToString(“s”));

Advertisements
Tagged with: ,
Posted in CRM 4
One comment on “Putting a DateTime value in a CrmDateTime field
  1. Raz says:

    Hi, thanks for the post, but the code does not work for CRM 4, there is no constructor for CrmDateTime which takes parameters 😦

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: