{"id":25211,"date":"2021-01-05T11:53:00","date_gmt":"2021-01-05T11:53:00","guid":{"rendered":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/?p=25211"},"modified":"2021-11-24T10:23:56","modified_gmt":"2021-11-24T10:23:56","slug":"to-calculate-number-of-months-between-two-dates","status":"publish","type":"post","link":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2021\/01\/05\/to-calculate-number-of-months-between-two-dates\/","title":{"rendered":"To calculate number of months between two dates"},"content":{"rendered":"\n<p>Many times we come across a requirement where you require to calculate the number of months between two Dates. In our blog, we will explain how you can achieve this.<\/p>\n\n\n\n<p><strong><em>New Stuff:<\/em><\/strong><a href=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2020\/12\/03\/steps-to-implement-delete-order-functionality-in-gumu-sage-crm-sage-100-integration\/\">Steps to implement Delete Order functionality in GUMU Sage CRM \u2013 Sage 100 Integration<\/a><\/p>\n\n\n\n<p>Lets, take an example where we need to calculate the difference of months between two date fields. Here we have created Start Date and Close Date fields against the company entity to find the age of the company in months.<\/p>\n\n\n\n<a href=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-content\/uploads\/2021\/01\/1-1.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"size-full\" style=\"border: 1px solid #A9A9A9; padding: 2px; margin: 2px;\" src=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-content\/uploads\/2021\/01\/1-1.png\" alt=\"Fields Added \"><\/a><font size=\"2\"><center><i>Fields Added<\/i><\/center><\/font>\n\n\n\n<p>First step is to create 3 new fields against company as displayed in above image.<\/p>\n\n\n\n<ul class=\"wp-block-list\" type=\"1\"><li>Navigate to below path<br>&lt;&lt;Sage CRM Installation Directory&gt;&gt;\\ \\&lt;&lt;CRMINSTANCENAME&gt;&gt;\\WWWRoot\\js\\custom<\/li><\/ul>\n\n\n\n<ul class=\"wp-block-list\"><li>Create a new js.file and insert the below code<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>var sStartDate = document.getElementById('claus_start_date').value;\nvar sCloseDate = document.getElementById('claus_close_date').value;\nvar sDate = sStartDate.substring(0, 2);\nvar sMonth = sStartDate.substring(3, 5);\nsMonth--;\nvar sMon = sMonth;\nvar sYear = sStartDate.substring(6, 10);\nvar sDate1 = sCloseDate.substring(0, 2);\nvar sMonth1 = sCloseDate.substring(3, 5);\nsMonth1--;\nvar sMon1 = sMonth1;\nvar sYear1 = sCloseDate.substring(6, 10);\t\nvar FormattedStartDate = new Date(sYear, sMon, sDate);\nvar FormattedCloseDate = new Date(sYear1, sMon1, sDate1);\nvar Diff = FormattedCloseDate-FormattedStartDate;\nvar DiffDays = Math.ceil(Diff \/ (1000 * 60 * 60 * 24)); \nvar DiffMonths = Math.floor(DiffDays \/ 30);\t\t   \n claus_diff_months.value = DiffMonths;\n<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\" type=\"1\"><li>Log on to Sage CRM<\/li><li>Navigate to below path<br>Administration | Customization<\/li><li>Choose the entity and navigate to screen.<\/li><li>In On change script of Close Date field, add the required function.<\/li><\/ul>\n\n\n\n<a href=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-content\/uploads\/2021\/01\/2-1.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"size-full\" style=\"border: 1px solid #A9A9A9; padding: 2px; margin: 2px;\" src=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-content\/uploads\/2021\/01\/2-1.png\" alt=\"Updated Calculation \"><\/a><font size=\"2\"><center><i>Updated Calculation<\/i><\/center><\/font>\n\n\n\n<p>Once you are done you should find the months calculated for the entered dates. Hope this information helps!<\/p>\n\n\n\n<p><span style=\"font-size: Medium;\"><strong>About Us<\/strong><\/span><\/p>\n\n\n\n<p>Greytrix \u2013 a globally recognized and one of the oldest Sage Development Partners is a one-stop solution provider for Sage ERP and Sage CRM organizational needs. Being acknowledged and rewarded for multi-man years of experience and expertise, we bring complete end-to-end assistance for your technical consultations, product customizations, data migration, system integrations, third-party add-on development, and implementation competence.<\/p>\n\n\n\n<p>Greytrix\u00a0has some unique integration solutions developed for Sage CRM with Sage ERPs namely\u00a0Sage X3,\u00a0Sage Intacct,\u00a0Sage 100,\u00a0Sage 500,\u00a0and\u00a0Sage 300. We also offer best-in-class\u00a0Sage ERP\u00a0and\u00a0Sage CRM\u00a0customization and development services\u00a0to\u00a0Business\u00a0Partners,\u00a0End\u00a0Users, and Sage PSG worldwide. Greytrix\u00a0helps in\u00a0the migration of Sage CRM from\u00a0Salesforce | ACT! | SalesLogix | Goldmine | Sugar CRM | Maximizer. Our Sage CRM Product Suite includes\u00a0add-ons like\u00a0 Greytrix Business Manager,\u00a0Sage CRM Project Manager,\u00a0Sage CRM Resource Planner,\u00a0Sage CRM Contract Manager,\u00a0Sage CRM Event Manager,\u00a0Sage CRM Budget Planner,\u00a0Gmail Integration,\u00a0Sage CRM Mobile Service Signature,\u00a0Sage CRM CTI Framework.<gwmw style=\"display:none;\"><gwmw style=\"display:none;\"><gwmw style=\"display:none;\"><gwmw style=\"display:none;\"><\/gwmw><\/gwmw><gwmw style=\"display:none;\"><\/gwmw><\/gwmw><\/gwmw><\/p>\n\n\n\n<p>Greytrix is a recognized\u00a0Sage Champion Partner\u00a0for GUMU&#x2122; Sage X3 \u2013 Sage CRM integration listed on\u00a0Sage Marketplace and Sage CRM \u2013 Sage Intacct integration listed on Sage Intacct Marketplace. The GUMU&#x2122; Cloud framework by Greytrix forms the backbone of cloud integrations that are managed in real-time for the processing and execution of application programs at the click of a button.<gwmw style=\"display:none;\"><gwmw style=\"display:none;\"><gwmw style=\"display:none;\"><gwmw style=\"display:none;\"><\/gwmw><\/gwmw><gwmw style=\"display:none;\"><\/gwmw><\/gwmw><\/gwmw><\/p>\n\n\n\n<p>For more information on our integration solutions, please contact us at&nbsp;<a href=\"mailto:sage@greytrix.com\">sage@greytrix.com<\/a>. We will be glad to assist you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Many times we come across a requirement where you require to calculate the number of months between two Dates. In our blog, we will explain how you can achieve this. New Stuff:Steps to implement Delete Order functionality in GUMU Sage CRM \u2013 Sage 100 Integration Lets, take an example where we need to calculate the\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2021\/01\/05\/to-calculate-number-of-months-between-two-dates\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[332,103,204,268,352],"tags":[4306,4248,1695,2232],"class_list":["post-25211","post","type-post","status-publish","format-standard","hentry","category-sage-crm","category-date","category-js-file","category-onchangescript","category-script","tag-calculate-months","tag-companys-summary-screen","tag-on-change","tag-script"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>To calculate number of months between two dates - 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\/2021\/01\/05\/to-calculate-number-of-months-between-two-dates\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"To calculate number of months between two dates - Sage CRM \u2013 Tips, Tricks and Components\" \/>\n<meta property=\"og:description\" content=\"Many times we come across a requirement where you require to calculate the number of months between two Dates. In our blog, we will explain how you can achieve this. New Stuff:Steps to implement Delete Order functionality in GUMU Sage CRM \u2013 Sage 100 Integration Lets, take an example where we need to calculate the\u2026 Read More &raquo;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2021\/01\/05\/to-calculate-number-of-months-between-two-dates\/\" \/>\n<meta property=\"og:site_name\" content=\"Sage CRM \u2013 Tips, Tricks and Components\" \/>\n<meta property=\"article:published_time\" content=\"2021-01-05T11:53:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-11-24T10:23:56+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-content\/uploads\/2021\/01\/1-1.png\" \/>\n<meta name=\"author\" content=\"Greytrix\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Greytrix\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2021\/01\/05\/to-calculate-number-of-months-between-two-dates\/\",\"url\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2021\/01\/05\/to-calculate-number-of-months-between-two-dates\/\",\"name\":\"To calculate number of months between two dates - Sage CRM \u2013 Tips, Tricks and Components\",\"isPartOf\":{\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2021\/01\/05\/to-calculate-number-of-months-between-two-dates\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2021\/01\/05\/to-calculate-number-of-months-between-two-dates\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-content\/uploads\/2021\/01\/1-1.png\",\"datePublished\":\"2021-01-05T11:53:00+00:00\",\"dateModified\":\"2021-11-24T10:23:56+00:00\",\"author\":{\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/#\/schema\/person\/402abe5da07cd7f9bfeb6acfa41fae39\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2021\/01\/05\/to-calculate-number-of-months-between-two-dates\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2021\/01\/05\/to-calculate-number-of-months-between-two-dates\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2021\/01\/05\/to-calculate-number-of-months-between-two-dates\/#primaryimage\",\"url\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-content\/uploads\/2021\/01\/1-1.png\",\"contentUrl\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-content\/uploads\/2021\/01\/1-1.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2021\/01\/05\/to-calculate-number-of-months-between-two-dates\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"To calculate number of months between two dates\"}]},{\"@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\/402abe5da07cd7f9bfeb6acfa41fae39\",\"name\":\"Greytrix\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/3cdb553d6ca07df0e407d5e092f2410d163e0fd40b27734b345b04c8f0786969?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/3cdb553d6ca07df0e407d5e092f2410d163e0fd40b27734b345b04c8f0786969?s=96&d=mm&r=g\",\"caption\":\"Greytrix\"},\"url\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/author\/greytrix\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"To calculate number of months between two dates - 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\/2021\/01\/05\/to-calculate-number-of-months-between-two-dates\/","og_locale":"en_US","og_type":"article","og_title":"To calculate number of months between two dates - Sage CRM \u2013 Tips, Tricks and Components","og_description":"Many times we come across a requirement where you require to calculate the number of months between two Dates. In our blog, we will explain how you can achieve this. New Stuff:Steps to implement Delete Order functionality in GUMU Sage CRM \u2013 Sage 100 Integration Lets, take an example where we need to calculate the\u2026 Read More &raquo;","og_url":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2021\/01\/05\/to-calculate-number-of-months-between-two-dates\/","og_site_name":"Sage CRM \u2013 Tips, Tricks and Components","article_published_time":"2021-01-05T11:53:00+00:00","article_modified_time":"2021-11-24T10:23:56+00:00","og_image":[{"url":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-content\/uploads\/2021\/01\/1-1.png","type":"","width":"","height":""}],"author":"Greytrix","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Greytrix","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2021\/01\/05\/to-calculate-number-of-months-between-two-dates\/","url":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2021\/01\/05\/to-calculate-number-of-months-between-two-dates\/","name":"To calculate number of months between two dates - Sage CRM \u2013 Tips, Tricks and Components","isPartOf":{"@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2021\/01\/05\/to-calculate-number-of-months-between-two-dates\/#primaryimage"},"image":{"@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2021\/01\/05\/to-calculate-number-of-months-between-two-dates\/#primaryimage"},"thumbnailUrl":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-content\/uploads\/2021\/01\/1-1.png","datePublished":"2021-01-05T11:53:00+00:00","dateModified":"2021-11-24T10:23:56+00:00","author":{"@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/#\/schema\/person\/402abe5da07cd7f9bfeb6acfa41fae39"},"breadcrumb":{"@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2021\/01\/05\/to-calculate-number-of-months-between-two-dates\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.greytrix.com\/blogs\/sagecrm\/2021\/01\/05\/to-calculate-number-of-months-between-two-dates\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2021\/01\/05\/to-calculate-number-of-months-between-two-dates\/#primaryimage","url":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-content\/uploads\/2021\/01\/1-1.png","contentUrl":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-content\/uploads\/2021\/01\/1-1.png"},{"@type":"BreadcrumbList","@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2021\/01\/05\/to-calculate-number-of-months-between-two-dates\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/"},{"@type":"ListItem","position":2,"name":"To calculate number of months between two dates"}]},{"@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\/402abe5da07cd7f9bfeb6acfa41fae39","name":"Greytrix","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/3cdb553d6ca07df0e407d5e092f2410d163e0fd40b27734b345b04c8f0786969?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3cdb553d6ca07df0e407d5e092f2410d163e0fd40b27734b345b04c8f0786969?s=96&d=mm&r=g","caption":"Greytrix"},"url":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/author\/greytrix\/"}]}},"_links":{"self":[{"href":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-json\/wp\/v2\/posts\/25211","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\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-json\/wp\/v2\/comments?post=25211"}],"version-history":[{"count":2,"href":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-json\/wp\/v2\/posts\/25211\/revisions"}],"predecessor-version":[{"id":25977,"href":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-json\/wp\/v2\/posts\/25211\/revisions\/25977"}],"wp:attachment":[{"href":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-json\/wp\/v2\/media?parent=25211"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-json\/wp\/v2\/categories?post=25211"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-json\/wp\/v2\/tags?post=25211"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}