{"id":505,"date":"2014-03-29T05:50:53","date_gmt":"2014-03-29T05:50:53","guid":{"rendered":"http:\/\/www.greytrix.com\/blogs\/salesforce\/?p=505"},"modified":"2025-05-29T06:44:17","modified_gmt":"2025-05-29T06:44:17","slug":"calculating-the-time-taken-between-two-dates","status":"publish","type":"post","link":"https:\/\/www.greytrix.com\/blogs\/salesforce\/2014\/03\/29\/calculating-the-time-taken-between-two-dates\/","title":{"rendered":"Calculating the time taken between two dates"},"content":{"rendered":"\n<p>While working on a project we had to display the time difference between two field values. We had two date fields where the user could enter a start date and end date for a task. We had to display the total time taken between the start date and end date in a separate field. We can do this by using the salesforce formula field.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2014\/03\/datediffgt0.png\"><img decoding=\"async\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2014\/03\/datediffgt0.png\" alt=\"datediffgt0\" class=\"wp-image-514\"\/><\/a><\/figure><\/div>\n\n\n<p>To do this, create a formula field that will return Text as the formula return type. Insert the following formula \u2013&nbsp;<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2014\/03\/datediffgt1.png\"><img decoding=\"async\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2014\/03\/datediffgt1.png\" alt=\"datediffgt1\" class=\"wp-image-515\"\/><\/a><\/figure><\/div>\n\n\n<p>Now our formula field will calculate the time taken from the start date and the end date and display the result in the number of days, hours and minutes as shown in below screenshot.<br><span style=\"font-size: Medium;\"><strong>About Us<\/strong><\/span><br><a href=\"https:\/\/www.greytrix.com\/\">Greytrix<\/a> as a Salesforce Product development partner offers a wide variety of integration products and services to the end users as well as to the Partners across the globe. We offers Consultation, Configuration, Training and support services in out-of-the-box functionality as well as customizations to incorporate custom business rules and functionalities that requires apex code incorporation into the Salesforce platform.<\/p>\n\n\n\n<p><a href=\"https:\/\/www.greytrix.com\/\">Greytrix<\/a> has some unique solutions for Cloud CRM such as Salesforce integration with <a href=\"https:\/\/www.greytrix.com\/product\/sage-x3\/gumu-x3-salesforce-integration\">Sage Enterprise Management (Sage X3<\/a>), Sage Intacct, <a href=\"https:\/\/www.greytrix.com\/product\/sage-100-erp\/gumu-100-salesforce-integration\">Sage 100 <\/a>and <a href=\"https:\/\/www.greytrix.com\/product\/sage-300-erp\/gumu-300-salesforce-integration\">Sage 300 (Sage Accpac)<\/a>. We also offer best-in-class Cloud CRM <a href=\"https:\/\/www.greytrix.com\/product\/crm-development\/salesforce-com\">Salesforce customization and development services<\/a> along with services such as Salesforce <a href=\"https:\/\/www.greytrix.com\/product\/professional-services\/data-migration-services\">Data Migration<\/a>, <a href=\"https:\/\/www.greytrix.com\/product\/professional-services\/integrated-application-development\">Integrated App development<\/a>, <a href=\"https:\/\/www.greytrix.com\/product\/professional-services\/custom-development\">Custom App development<\/a> and <a href=\"https:\/\/www.greytrix.com\/product\/professional-services\/maintenance-support\">Technical Support<\/a> to business partners and end users.<\/p>\n\n\n\n<p>Greytrix GUMU&#x2122; integration for Sage ERP \u2013 Salesforce is a 5-star app listed on <a href=\"https:\/\/appexchange.salesforce.com\/listingDetail?listingId=a0N30000000psM5EAI\" target=\"_blank\" rel=\"noopener\">Salesforce AppExchange<\/a>.<\/p>\n\n\n\n<p>For more information, please contact us at <a href=\"mailto:salesforce@greytrix.com\">salesforce@greytrix.com<\/a>. We will be glad to assist you.<\/p>\n\n\n\n<p><strong><span style=\"font-size: Medium;\">Related Posts<\/span><\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a title=\"Changing user email without asking for confirmation from user\" href=\"http:\/\/www.greytrix.com\/blogs\/salesforce\/2014\/03\/28\/changing-user-email-without-asking-for-confirmation-from-user\/\" target=\"_blank\" rel=\"noopener\">Changing user email without asking for confirmation from user<\/a><\/li>\n\n\n\n<li><a title=\"Remove New button from Lookup Window for Account and Contact Object\" href=\"http:\/\/www.greytrix.com\/blogs\/salesforce\/2014\/03\/21\/remove-new-button-from-lookup-window-for-account-and-contact-object\/\" target=\"_blank\" rel=\"noopener\">Remove New button from Lookup Window for Account and Contact Object<\/a><\/li>\n\n\n\n<li><a title=\"Indent Apex Code in Eclipse\" href=\"http:\/\/www.greytrix.com\/blogs\/salesforce\/2014\/03\/12\/indent-apex-code-in-eclipse\/\" target=\"_blank\" rel=\"noopener\">Indent Apex Code in Eclipse<\/a><\/li>\n\n\n\n<li><a title=\"Dynamic File Name for Exported PDF\" href=\"http:\/\/www.greytrix.com\/blogs\/salesforce\/2014\/03\/01\/dynamic-file-name-for-exported-pdf\/\" target=\"_blank\" rel=\"noopener\">Dynamic File Name for Exported PDF<\/a><\/li>\n\n\n\n<li><a title=\"Using same component multiple times in a Visualforce page\" href=\"http:\/\/www.greytrix.com\/blogs\/salesforce\/2014\/02\/18\/using-same-component-multiple-times-in-a-visualforce-page\/\" target=\"_blank\" rel=\"noopener\">Using same component multiple times in a Visualforce page<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>While working on a project we had to display the time difference between two field values. We had two date fields where the user could enter a start date and end date for a task. We had to display the total time taken between the start date and end date in a separate field. We\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2014\/03\/29\/calculating-the-time-taken-between-two-dates\/\">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":[3],"tags":[575,82,137,576],"class_list":["post-505","post","type-post","status-publish","format-standard","hentry","category-salesforce-srv","tag-calculate-time","tag-dates","tag-formula-field","tag-time-beween-dates"],"_links":{"self":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts\/505","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/comments?post=505"}],"version-history":[{"count":2,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts\/505\/revisions"}],"predecessor-version":[{"id":10503,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts\/505\/revisions\/10503"}],"wp:attachment":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/media?parent=505"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/categories?post=505"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/tags?post=505"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}