Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: DateDiff calculation Post Reply Post New Topic
Author Message
ReportWriter14
Newbie
Newbie


Joined: 20 Jan 2014
Online Status: Offline
Posts: 4
Quote ReportWriter14 Replybullet Topic: DateDiff calculation
     Posted: 14 Apr 2014 at 8:30am
I am attempting to calculate late orders from vendors using a report. We want to give 1 day of leeway late and IDEALLY skip weekends and Holidays. From there we want to calculate their on time delivery percentage. Maybe there is a different way to do this, but I am trying to use DateDiff.

  1. Today I am using this formula to determine if it is late or not:

    If DateDiff ("d", {V_PO_LINES.ORIG_DUE_DATE}, {V_PO_LINES.DATE_LAST_RECEIVED}) > 1 Then 0 else 1


    I don't care if it is early, but if it is late it creates production issues. So we give 1 day of leeway. The issue is using date diff, I can only see the number of days difference. If the Due Date is Friday and we don't get it until Monday, that would be technically within our 1 day of leeway. Or if today is Wednesday and we have Thursday as a Holiday, I wouldn't want to count it.

  2. From there I am calculating an on time delivery percentage:

    Sum ({@Date_Compare}, {V_PO_LINES.VENDOR}) / Count ({@Date_Compare}, {V_PO_LINES.VENDOR}) * 100

I would think we should be able to get the 1 day / weekend thing captured but Holidays is another beast entirely. We would probably even be happy manually allowing for Holidays. There is no mechanism in the system that says what dates are holidays.
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 14 Apr 2014 at 10:10am
You can find the day of the week easily enough (WeekDay or DayOfWeek functions).

For holidays, from what I have seen you either need a table with the holidays or I have seen a formula that finds US holidays.
IP IP Logged
ReportWriter14
Newbie
Newbie


Joined: 20 Jan 2014
Online Status: Offline
Posts: 4
Quote ReportWriter14 Replybullet Posted: 14 Apr 2014 at 10:14am
Thanks! Great call. The If statement will turn into a beast but it is doable. I can build out a table for the Holidays and do a check against that as well as the day of the week... Just not thinking too deep today.
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum