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, 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’t 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.
We need to create two different formulas, one for calculating Days to ship and other for Days late.
Calculation Needed:
Days To Ship= Invoice Date – Order Date(exclude weekends)
Days Late= Invoice Date – Promise(Shipment) Date (exclude weekends)
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:
Date and Time Function includes:
Current Date : This function display the current date.
Current Time: This function display the current time.
DayOfWeek(): This function diplays the day of the specified date.
Syntax: DayOfWeek(date)
DateAdd(): The DateAdd() function can be used to add an interval of time to a date.
Syntax: DateAdd(interval type,number,start date)
DateDiff():The DateDiff() function is used to calculate date difference between two dates.
Syntax: DateDiff(interval type,date 1,date 2)
DatePart(): The DatePart() function returns the part of a date such as a day, month and year.
Syntax: DatePart(date_part,input date)
Interval type description:
yyyy: years
d: Day
m: month
w: Weekday
ww: Weeks
q : quarters
h: hours
m: minutes
s: second
As we have to calculate here difference between two dates we will use DateDiff() function.
Crystal Formula to exclude weekends:
Set Variables for the fields to be used in the calculation.
Define the variable of datatype datetime to be used in the calculation i.e. d1 and d2.
Formula to calculate Days to Ship:
DateTimeVar d1:= {SORDER.ORDDAT};
DateTimeVar d2:={SINVOICE.ACCDAT};
DateDiff(“d”,d1,d2)-DateDiff(“ww”,d1,d2,crSaturday)- DateDiff(“ww”,d1,d2)
Formula to calculate Days Late:
DateTimeVar d1:= {SORDER.SHIDAT};
DateTimeVar d2:={SINVOICE.ACCDAT};
DateDiff(“d”,d1,d2)-DateDiff(“ww”,d1,d2,crSaturday)- DateDiff(“ww”,d1,d2)
Where “d” is no. of days
“ww” is no. of weeks
“crSaturday” is used to exclude all the saturday between dates
“crSunday” is used to exclude all the sunday between dates
This blog help us to calculate the number of days between two different dates using date function i.e DateDiff() excluding the weekends.
About Us
Greytrix – 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.
Greytrix has some unique integration solutions developed for Sage CRM with Sage ERPs namely Sage X3, Sage Intacct, Sage 100, Sage 500, and Sage 300. We also offer best-in-class Sage ERP and Sage CRM customization and development services to Business Partners, End Users, and Sage PSG worldwide. Greytrix helps in the migration of Sage CRM from Salesforce | ACT! | SalesLogix | Goldmine | Sugar CRM | Maximizer. Our Sage CRM Product Suite includes addons like Greytrix Business Manager, Sage CRM Project Manager, Sage CRM Resource Planner, Sage CRM Contract Manager, Sage CRM Event Manager, Sage CRM Budget Planner, Gmail Integration, Sage CRM Mobile Service Signature, Sage CRM CTI Framework.
Greytrix is a recognized Sage Champion Partner for GUMU™ Sage X3 – Sage CRM integration listed on Sage Marketplace and Sage CRM – Sage Intacct integration listed on Sage Intacct Marketplace. The GUMU™ 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.
For more information on our integration solutions, please contact us at sage@greytrix.com. We will be glad to assist you.