Set CRM DateTime


Some time we need to set crmdatetime based on input value for year,month,date so we can create datatime variable in .net as

DateTime _DateTime=new DateTime(2010,4,15);  

so it will result like “4/15/2010 00:00:00”

But if you will try to assign this value to crmdatetime like

CrmDateTime _CrmDateTime = new CrmDateTime();
_CrmDateTime.Value=_DateTime.ToString();

you will get a date-time format exception in crm As CrmDateTime class expects the date in a certain format. like below

like  “2010/4/15T00:00:00”;

So you have to assign this value to crmdatetime like below

_CrmDateTime.Value=_DateTime.ToString(“s”);

Good luck !!!!

Advertisements

1 Comment

Filed under MS CRM 4.0

One response to “Set CRM DateTime

  1. Pingback: 2010 in review « Mahender Pal

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