{"id":270,"date":"2010-11-03T12:43:00","date_gmt":"2010-11-03T12:43:00","guid":{"rendered":"http:\/\/www.greytrix.com\/blogs\/sagecrm\/?p=270"},"modified":"2010-11-03T12:43:00","modified_gmt":"2010-11-03T12:43:00","slug":"error-saving-value-in-date-field","status":"publish","type":"post","link":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2010\/11\/03\/error-saving-value-in-date-field\/","title":{"rendered":"Error saving value in Date field"},"content":{"rendered":"<p>What all methods do we need while updating data to the CRM database? We can use CreateRecord, FindRecord or either simple Update query and ExecSql can also update the data in CRM database as per our need. Now the hitch is always when the date field comes into picture. Consider the scenario, you have created entry screen and this screen has the date field in it. Now if you are using standard container.execute command there will be no problem in saving date value to table, however if you are manually updating the date value in the recordset found using FindRecord method it needs some more things to be taken care of. Well in this case we need to pass the exact compatible formatted date value to date field before applying save changes. To do the same you can follow some easy steps below.<\/p>\n<p>1. The idea is in getting date in mm\/dd\/yyyy format as the date value in date field comes as per the user date format.<\/p>\n<p>2. For this first of all we need to find the date format for current logged in user. Below post of mine on this blog site will help you to achieve the same.<\/p>\n<p><a href=\"http:\/\/sagecrmaddons.blogspot.com\/2009\/02\/retrieve-current-logged-in-users-date.html\" target=\"_blank\" rel=\"noopener\">http:\/\/sagecrmaddons.blogspot.com\/2009\/02\/retrieve-current-logged-in-users-date.html<\/a><\/p>\n<p>3. Suppose here the date format is set as dd\/mm\/yyyy, so on screen we will get the date in same format. E.g. 23March2010 will look like 20\/03\/2010 in date field on screen. <\/p>\n<p>4. Now if we use Request.Form method to retrieve the value from form, the value we will get is 20\/03\/2010 i.e. in dd\/mm\/yyyy format.<\/p>\n<p>5. Now as we know that the user date format is dd\/mm\/yyyy we can convert the date value collected from the form into string and the split it using the appropriate separator as that of the date format i.e. slash or dot etc.<\/p>\n<p>6. Splitting the date string will get us the 3 different values always. Now we just need to identify what is the&nbsp;&nbsp;&nbsp;&nbsp; date, which one is month and which one is year.<\/p>\n<p>7. Based on the date format of the user we can retrieve 3 values needed to format date as explained above.<\/p>\n<p>8. Then we can concatenate these 3 parameters in string to get the string in mm\/dd\/yyyy format.<\/p>\n<p>9. Now this date has to be converted to UTC date which can be done as follows.<\/p>\n<p>&nbsp;&nbsp;&nbsp; Var Newdate = new Date( );<\/p>\n<p>&nbsp;&nbsp;&nbsp; Newdate = Newdate.getVarDate();<\/p>\n<p>10. You can assign the Newdate found above to recordset column while saving the data using CreateRecord\/FindRecord and SaveChanges method.<\/p>\n<p>Doing this for every date field will be quite cumbersome task and hence you can write a global function to carry out this task where you can pass the form date value to get the database compatible value as output. However if we are updating using update query, we just need to arrange the string in mm\/dd\/yyyy format and pass it in query. Rest all will be handled by SQL itself.<\/p>\n<p><marquee width=\"80%\"><b>For queries regarding the functionality, please feel free to drop us an email at <a href=\"mailto:crm@greytrix.com\" title=\"mailto:crm@greytrix.com\">crm@greytrix.com<\/a>. <\/b><\/marquee><\/p>\n","protected":false},"excerpt":{"rendered":"<p>What all methods do we need while updating data to the CRM database? We can use CreateRecord, FindRecord or either simple Update query and ExecSql can also update the data in CRM database as per our need. Now the hitch is always when the date field comes into picture. Consider the scenario, you have created\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2010\/11\/03\/error-saving-value-in-date-field\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[332],"tags":[908,924],"class_list":["post-270","post","type-post","status-publish","format-standard","hentry","category-sage-crm","tag-dashboard-error","tag-date"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Error saving value in Date field - Sage CRM \u2013 Tips, Tricks and Components<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2010\/11\/03\/error-saving-value-in-date-field\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Error saving value in Date field - Sage CRM \u2013 Tips, Tricks and Components\" \/>\n<meta property=\"og:description\" content=\"What all methods do we need while updating data to the CRM database? We can use CreateRecord, FindRecord or either simple Update query and ExecSql can also update the data in CRM database as per our need. Now the hitch is always when the date field comes into picture. Consider the scenario, you have created\u2026 Read More &raquo;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2010\/11\/03\/error-saving-value-in-date-field\/\" \/>\n<meta property=\"og:site_name\" content=\"Sage CRM \u2013 Tips, Tricks and Components\" \/>\n<meta property=\"article:published_time\" content=\"2010-11-03T12:43:00+00:00\" \/>\n<meta name=\"author\" content=\"greysagecrm\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"greysagecrm\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2010\/11\/03\/error-saving-value-in-date-field\/\",\"url\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2010\/11\/03\/error-saving-value-in-date-field\/\",\"name\":\"Error saving value in Date field - Sage CRM \u2013 Tips, Tricks and Components\",\"isPartOf\":{\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/#website\"},\"datePublished\":\"2010-11-03T12:43:00+00:00\",\"author\":{\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/#\/schema\/person\/e7ff1c8f4763b47730d6bc5e74d59c1f\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2010\/11\/03\/error-saving-value-in-date-field\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2010\/11\/03\/error-saving-value-in-date-field\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2010\/11\/03\/error-saving-value-in-date-field\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Error saving value in Date field\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/#website\",\"url\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/\",\"name\":\"Sage CRM \u2013 Tips, Tricks and Components\",\"description\":\"Explore the possibilities with Sage CRM insights through our comprehensive blogs. As a leading Sage partner, Greytrix helps businesses maximize their Sage CRM potential with its rich expertise and immense knowledge. Here, you will find blogs that feature expert advice, tips &amp; tricks, best practices, and comprehensive guides on customizing and configuring Sage CRM for your business. Stay informed with our regular updates and expert insights!\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/#\/schema\/person\/e7ff1c8f4763b47730d6bc5e74d59c1f\",\"name\":\"greysagecrm\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/c3b4325cb326e36467f945b9b9adf2bb85e907fe092d42eb36b39743b492e626?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/c3b4325cb326e36467f945b9b9adf2bb85e907fe092d42eb36b39743b492e626?s=96&d=mm&r=g\",\"caption\":\"greysagecrm\"},\"url\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/author\/greysagecrm\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Error saving value in Date field - Sage CRM \u2013 Tips, Tricks and Components","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2010\/11\/03\/error-saving-value-in-date-field\/","og_locale":"en_US","og_type":"article","og_title":"Error saving value in Date field - Sage CRM \u2013 Tips, Tricks and Components","og_description":"What all methods do we need while updating data to the CRM database? We can use CreateRecord, FindRecord or either simple Update query and ExecSql can also update the data in CRM database as per our need. Now the hitch is always when the date field comes into picture. Consider the scenario, you have created\u2026 Read More &raquo;","og_url":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2010\/11\/03\/error-saving-value-in-date-field\/","og_site_name":"Sage CRM \u2013 Tips, Tricks and Components","article_published_time":"2010-11-03T12:43:00+00:00","author":"greysagecrm","twitter_card":"summary_large_image","twitter_misc":{"Written by":"greysagecrm","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2010\/11\/03\/error-saving-value-in-date-field\/","url":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2010\/11\/03\/error-saving-value-in-date-field\/","name":"Error saving value in Date field - Sage CRM \u2013 Tips, Tricks and Components","isPartOf":{"@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/#website"},"datePublished":"2010-11-03T12:43:00+00:00","author":{"@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/#\/schema\/person\/e7ff1c8f4763b47730d6bc5e74d59c1f"},"breadcrumb":{"@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2010\/11\/03\/error-saving-value-in-date-field\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.greytrix.com\/blogs\/sagecrm\/2010\/11\/03\/error-saving-value-in-date-field\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2010\/11\/03\/error-saving-value-in-date-field\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/"},{"@type":"ListItem","position":2,"name":"Error saving value in Date field"}]},{"@type":"WebSite","@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/#website","url":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/","name":"Sage CRM \u2013 Tips, Tricks and Components","description":"Explore the possibilities with Sage CRM insights through our comprehensive blogs. As a leading Sage partner, Greytrix helps businesses maximize their Sage CRM potential with its rich expertise and immense knowledge. Here, you will find blogs that feature expert advice, tips &amp; tricks, best practices, and comprehensive guides on customizing and configuring Sage CRM for your business. Stay informed with our regular updates and expert insights!","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/#\/schema\/person\/e7ff1c8f4763b47730d6bc5e74d59c1f","name":"greysagecrm","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/c3b4325cb326e36467f945b9b9adf2bb85e907fe092d42eb36b39743b492e626?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c3b4325cb326e36467f945b9b9adf2bb85e907fe092d42eb36b39743b492e626?s=96&d=mm&r=g","caption":"greysagecrm"},"url":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/author\/greysagecrm\/"}]}},"_links":{"self":[{"href":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-json\/wp\/v2\/posts\/270","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-json\/wp\/v2\/comments?post=270"}],"version-history":[{"count":0,"href":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-json\/wp\/v2\/posts\/270\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-json\/wp\/v2\/media?parent=270"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-json\/wp\/v2\/categories?post=270"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-json\/wp\/v2\/tags?post=270"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}