{"id":20439,"date":"2020-08-25T09:43:06","date_gmt":"2020-08-25T09:43:06","guid":{"rendered":"http:\/\/www.greytrix.com\/blogs\/sagex3\/?p=20439"},"modified":"2024-07-03T11:25:57","modified_gmt":"2024-07-03T11:25:57","slug":"how-to-exclude-weekends-from-total-number-of-days-in-crystal-report","status":"publish","type":"post","link":"https:\/\/www.greytrix.com\/blogs\/sagex3\/2020\/08\/25\/how-to-exclude-weekends-from-total-number-of-days-in-crystal-report\/","title":{"rendered":"How to Exclude Weekends From Total Number of Days in Crystal Report"},"content":{"rendered":"<p>In sage X3, we have a functionality of printing various types of reports such as Order, Invoice, Payments, and Receipt etc. This report is created by using a crystal report. Crystal Report is a very powerful tool used to pull data from sage and present it in a ways you want.<\/p>\n<p>Sometimes in crystal report, we may have to develop sales history report. The report should show the Order No, Invoice No, order date, invoice date, shipment date, and how many days it takes to ship an order from the day we received the order until the day it is invoiced. We may also want to calculate how many days early or late based on the date promised to the customer. If the deliveries won\u2019t be done on weekends then in that case we may need to exclude the weekends from the number of days. Refer the below figure of report.<\/p>\n<p><a href=\"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-content\/uploads\/2020\/08\/Sales-History-Report.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\/sagex3\/wp-content\/uploads\/2020\/08\/Sales-History-Report.png\" alt=\"Sales History Report\" \/><\/a><\/p>\n<p>We need to create two different formulas, one for calculating Days to ship and other for Days late.<\/p>\n<p><strong>Calculation Needed:<\/strong><\/p>\n<p>Days To Ship= Invoice Date &#8211; Order Date(exclude weekends)<\/p>\n<p>Days Late= Invoice Date &#8211; Promise(Shipment) Date (exclude weekends)<\/p>\n<p>Crystal report has a various types of built in function and operators that includes String function, math function, date and time function, date ranges, arithmetic ,conversion, array operators, etc. We may use that pre-defined function to perform various calculation etc. Some of the Date Time function are as follows:<\/p>\n<p><strong>Date and Time Function includes:<\/strong><\/p>\n<p><strong>Current Date : <\/strong>This function display the current date.<\/p>\n<p><strong>Current Time:<\/strong> This function display the current time.<\/p>\n<p><strong>DayOfWeek()<\/strong>: This function diplays the day of the specified date.<\/p>\n<p><strong>Syntax: <\/strong>DayOfWeek(date)<\/p>\n<p><strong>DateAdd()<\/strong>: The DateAdd() function can be used to add an interval of time to a date.<\/p>\n<p><strong>Syntax:<\/strong> DateAdd(interval type,number,start date)<\/p>\n<p><strong>DateDiff()<\/strong>:The DateDiff() function is used to calculate date difference between two dates.<\/p>\n<p><strong>Syntax<\/strong>: DateDiff(interval type,date 1,date 2)<\/p>\n<p><strong>DatePart()<\/strong>: The DatePart() function returns the part of a date such as a day, month and year.<\/p>\n<p><strong>Syntax:<\/strong> DatePart(date_part,input date)<\/p>\n<p><strong>Interval type description:<\/strong><\/p>\n<p>yyyy:\u00a0\u00a0 years<\/p>\n<p>d:\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Day<\/p>\n<p>m:\u00a0\u00a0\u00a0\u00a0\u00a0 month<\/p>\n<p>w:\u00a0\u00a0\u00a0\u00a0\u00a0 Weekday<\/p>\n<p>ww:\u00a0\u00a0 Weeks<\/p>\n<p>\u00a0q :\u00a0\u00a0\u00a0\u00a0 quarters<\/p>\n<p>h:\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 hours<\/p>\n<p>m:\u00a0 \u00a0\u00a0\u00a0minutes<\/p>\n<p>s:\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 second<\/p>\n<p>As we have to calculate here difference between two dates we will use DateDiff() function.<\/p>\n<p><strong><u>Crystal Formula to exclude weekends:<\/u><\/strong><\/p>\n<p>Set Variables for the fields to be used in the calculation.<\/p>\n<p>Define the variable of datatype datetime to be used in the calculation i.e. d1 and d2.<\/p>\n<p><strong><u>Formula to calculate Days to Ship:<\/u><\/strong><\/p>\n<p>DateTimeVar d1:= {SORDER.ORDDAT};<\/p>\n<p>DateTimeVar d2:={SINVOICE.ACCDAT};<\/p>\n<p>DateDiff(\u201cd\u201d,d1,d2)-DateDiff(\u201cww\u201d,d1,d2,crSaturday)- DateDiff(\u201cww\u201d,d1,d2)<\/p>\n<p><strong><u>Formula to calculate Days Late:<\/u><\/strong><\/p>\n<p>DateTimeVar d1:= {SORDER.SHIDAT};<\/p>\n<p>DateTimeVar d2:={SINVOICE.ACCDAT};<\/p>\n<p>DateDiff(\u201cd\u201d,d1,d2)-DateDiff(\u201cww\u201d,d1,d2,crSaturday)- DateDiff(\u201cww\u201d,d1,d2)<\/p>\n<p>Where \u201cd\u201d is no. of days<\/p>\n<p>\u00a0\u201cww\u201d is no. of weeks<\/p>\n<p>\u00a0 \u201ccrSaturday\u201d is used to exclude all the saturday between\u00a0 dates<\/p>\n<p>\u00a0 \u00a0\u201ccrSunday\u201d is used to exclude all the sunday between\u00a0 dates<\/p>\n<p>This blog help us to calculate the number of days between two different dates using date function i.e DateDiff() excluding the weekends.<\/p>\n\n\n<h2 class=\"wp-block-heading\"><strong>About Us<\/strong><\/h2>\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 id=\"block-28013e99-0882-44c6-b705-7b16c85053b2\">Greytrix&nbsp;has some unique integration solutions developed for&nbsp;<a href=\"https:\/\/www.greytrix.com\/sage-crm\/\">Sage CRM<\/a>&nbsp;with Sage ERPs&nbsp;namely&nbsp;<a href=\"https:\/\/www.greytrix.com\/sage-x3-erp\/\">Sage X3<\/a>,&nbsp;<a href=\"https:\/\/www.greytrix.com\/sage-intacct\/\">Sage Intacct<\/a>,&nbsp;<a href=\"https:\/\/www.greytrix.com\/sage-100-erp\/\">Sage 100<\/a>,&nbsp;<a href=\"https:\/\/www.greytrix.com\/sage-500-erp\/\">Sage 500<\/a>,&nbsp;and&nbsp;<a href=\"https:\/\/www.greytrix.com\/sage-300-erp\/\">Sage 300<\/a>. We also offer best-in-class&nbsp;Sage ERP&nbsp;and&nbsp;Sage CRM&nbsp;customization and development services&nbsp;to&nbsp;Business&nbsp;Partners,&nbsp;End&nbsp;Users, and Sage PSG worldwide. Greytrix&nbsp;helps in&nbsp;the migration of Sage CRM from&nbsp;Salesforce | ACT! | SalesLogix | Goldmine | Sugar CRM | Maximizer. Our Sage CRM Product Suite includes&nbsp;addons like&nbsp;&nbsp;Greytrix Business Manager,&nbsp;Sage CRM Project Manager,&nbsp;Sage CRM Resource Planner,&nbsp;Sage CRM Contract Manager,&nbsp;Sage CRM Event Manager,&nbsp;Sage CRM Budget Planner,&nbsp;Gmail Integration,&nbsp;Sage CRM Mobile Service Signature,&nbsp;Sage CRM CTI Framework.<\/p>\n\n\n\n<p id=\"block-4bc42a09-fb13-4598-8137-ce5f7b91ce28\">Greytrix is a recognized&nbsp;Sage Champion Partner&nbsp;for GUMU&#x2122; Sage X3 \u2013 Sage CRM integration listed on&nbsp;<a href=\"https:\/\/www.sage.com\/marketplace\/asb_ListingDetail?listingId=a1h24000007PC3aAAG\" target=\"_blank\" rel=\"noreferrer noopener\">Sage Marketplace<\/a>&nbsp;and Sage CRM \u2013 Sage Intacct integration listed on&nbsp;<a href=\"https:\/\/marketplace.intacct.com\/MPListing?lid=a2D0H000007kiHyUAI\" target=\"_blank\" rel=\"noreferrer noopener\">Sage Intacct Marketplace<\/a>. The&nbsp;<a href=\"https:\/\/www.greytrix.com\/gumu\/\" target=\"_blank\" rel=\"noreferrer noopener\">GUMU&#x2122; Cloud framework<\/a>&nbsp;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.<\/p>\n\n\n\n<p id=\"block-76376301-1c3e-4250-8a09-727595a606f0\">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>In sage X3, we have a functionality of printing various types of reports such as Order, Invoice, Payments, and Receipt etc. This report is created by using a crystal report. Crystal Report is a very powerful tool used to pull data from sage and present it in a ways you want. Sometimes in crystal report,\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.greytrix.com\/blogs\/sagex3\/2020\/08\/25\/how-to-exclude-weekends-from-total-number-of-days-in-crystal-report\/\">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":[2796],"tags":[3053,3056,3055,3057,3054],"class_list":["post-20439","post","type-post","status-publish","format-standard","hentry","category-technical","tag-crystal-reports","tag-date-function","tag-datediff","tag-excluding-weekends","tag-number-of-days"],"_links":{"self":[{"href":"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-json\/wp\/v2\/posts\/20439","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-json\/wp\/v2\/comments?post=20439"}],"version-history":[{"count":3,"href":"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-json\/wp\/v2\/posts\/20439\/revisions"}],"predecessor-version":[{"id":29565,"href":"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-json\/wp\/v2\/posts\/20439\/revisions\/29565"}],"wp:attachment":[{"href":"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-json\/wp\/v2\/media?parent=20439"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-json\/wp\/v2\/categories?post=20439"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-json\/wp\/v2\/tags?post=20439"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}