If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Crystal Reports > Subtract Weekdays

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-13-09, 14:57
lucy68 lucy68 is offline
Registered User
 
Join Date: May 2009
Posts: 20
Subtract Weekdays

I am trying to write a formula to subtract the leadtime from the purchase order due date to give me the date the order needs to be placed.

CURDUE_10 is the due date of the purchase order.

PURLT_01 is the leadtime on the item in business days.

This formula (which came from the Crystal Reports help file) totally ignored the weekday part and just gives me due date minus leadtime days as calendar days:

DateAdd("w",-{Part_Master.PURLT_01},{Order_Master.CURDUE_10})

This formula (which I copied off a website and do not understand at all) worked great on the first record but then not so hot on the second and by the time it got 50 records down, it had order placement dates of three years ago so obviously something wasn't working at all:

numbervar counts;datevar lastday;datevar firstday;numbervar loops;
firstday:={Order_Master.CURDUE_10};

while counts <{Part_Master.PURLT_01} do(
loops:=loops+1;
if dayofweek(firstday+loops)in [2 to 6] then counts:=counts+1);

lastday:=firstday-loops

Help please!
Reply With Quote
  #2 (permalink)  
Old 05-28-09, 12:05
dsatino dsatino is offline
Registered User
 
Join Date: May 2009
Posts: 4
This formula should work:

DateAdd("d",-{Part_Master.PURLT_01},{Order_Master.CURDUE_10})

but it would be easier to simply write the function:

{Order_Master.CURDUE_10}-{Part_Master.PURLT_01}
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On