{"id":151,"date":"2010-04-15T09:27:45","date_gmt":"2010-04-15T09:27:45","guid":{"rendered":"http:\/\/mahenderpal.wordpress.com\/?p=151"},"modified":"2010-04-15T09:27:45","modified_gmt":"2010-04-15T09:27:45","slug":"set-crm-datetime","status":"publish","type":"post","link":"https:\/\/himbap.com\/blog\/?p=151","title":{"rendered":"Set CRM DateTime"},"content":{"rendered":"<p>Some time we need to set crmdatetime based on input value for year,month,date so we can create datatime variable in .net as<\/p>\n<p>DateTime _DateTime=new DateTime(2010,4,15);\u00a0\u00a0<\/p>\n<p>so it will result like &#8220;4\/15\/2010 00:00:00&#8221;<\/p>\n<p>But if you will try to assign this value to crmdatetime like<\/p>\n<p>CrmDateTime _CrmDateTime = new CrmDateTime();<br \/>\n_CrmDateTime.Value=_DateTime.ToString();<\/p>\n<p>you will get a\u00a0date-time format exception in crm As\u00a0CrmDateTime class expects the date in a certain format. like below<\/p>\n<p>like \u00a0&#8220;2010\/4\/15T00:00:00&#8221;;<\/p>\n<p>So you have to\u00a0assign this value to crmdatetime like below<\/p>\n<p>_CrmDateTime.Value=_DateTime.ToString(&#8220;s&#8221;);<\/p>\n<p>Good luck !!!!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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);\u00a0\u00a0 so it will result like &#8220;4\/15\/2010 00:00:00&#8221; But if you will try to assign this value to crmdatetime like CrmDateTime _CrmDateTime = new CrmDateTime(); _CrmDateTime.Value=_DateTime.ToString(); you will get a\u00a0date-time format exception in crm As\u00a0CrmDateTime class&#8230; <a href=\"https:\/\/himbap.com\/blog\/?p=151\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[10],"tags":[],"_links":{"self":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/151"}],"collection":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=151"}],"version-history":[{"count":0,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/151\/revisions"}],"wp:attachment":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=151"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=151"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=151"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}