Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Counting business days for an order 1

Status
Not open for further replies.
Jul 20, 2004
2
US
I have a report that gives information concerning backorders. I have been asked to revise this report to include a new column which will calculate the number of working days a particular order is in backorder status. They want the number of work days from the original order entry date to the date the backorder ships. I am unsure how to proceed with this formula, so if someone could give me a hand I would greatly appreciate it. I'm using Cyrstal 8.5 if it helps. Thanks!
 
Dear Devguy81,

You want the datediff function. You can look it up in Crystal's help so that you understand what the following is doing.

Code:
local datetimevar fd;
local datetimevar ld;
numbervar bdays;

fd:= {Table.OrderDate};

ld:= {Table.OrderDate};

 
bdays:= 
(
DateDiff ("d", fd, ld) - //minus sign
    DateDiff ("ww", fd, ld, crSaturday) -  //minus sign
    DateDiff ("ww", fd, ld, crSunday)
)  
;

if DayOfWeek (fd) in [1,7] then bdays := bdays -1;

bdays

[code]

By the way if it is off one day that would be because the datediff ('d') part here, doesn't count the first day, so just add 1 to the result.

regards,

ro

Rosemary Lieberman
rosemary-at-microflo.com, [URL unfurl="true"]www.microflo.com[/URL]
Microflo provides expert consulting on MagicTSD and Crystal Reports.

You will get answers more quickly if you read this before posting: faq149-3762
 
Dear Devguy,

I just noticed some typos ...

The variables should be datevar if your date fields are date, datetimevar if you datefields are datetime.

Also, where I set the value of ld ... I copied Table.OrderDate intending to change it to Table.ShipDate and apparently forgot....

Regards,

ro

Rosemary Lieberman
rosemary-at-microflo.com, Microflo provides expert consulting on MagicTSD and Crystal Reports.

You will get answers more quickly if you read this before posting: faq149-3762
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top