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 !!!!