Yes, I already have the code to determine the number of business days back 
(I'll copy the full code here in case anyone else finds it useful).  But the 
DNW function is so darn handy that I was just hoping for a reverse-DNW!

    -- Set the number of days to go backwards
    SET VAR vDays = (.vRDays + .vPDays + .vSDays)
    -- We start with the Due Date
    SET VAR vBDate = .vDDate

    SET VAR vCount INT = 0, vLoop INT = 1
    WHILE vLoop <= .vDays THEN
      SET VAR vTestDate = (.vBDate - 1)
      IF (IDWK(.vTestDate)) BETWEEN 1 AND 5 THEN
        SET VAR vLoop = (.vLoop + 1)
      ENDIF
      SET VAR vBDate = .vTestDate
    ENDWHILE


Karen


 

 

 

-----Original Message-----
From: Javier Valencia <[email protected]>
To: RBASE-L Mailing List <[email protected]>
Sent: Wed, May 6, 2015 1:15 pm
Subject: [RBASE-L] - RE: Previous business day function?


 
  
Karen,
  
 
  
Yu can probably use the following workaround;
  
SET VAR vDate DATE = .#DATE -- or whatever date you want
  
SET VAR vPWD = (IFEQ(TDWK(.vDate),'Monday',(.vDate -3),(.vDate-1)))
  
 
  
The function TDWK return the “Day” of the week as text.
  
Now, if your date is on a Monday, it will return the previous Friday, otherwise 
it will return the previous day. Just like the DFNW it does not consider 
holidays, although you can create stored function with lookup table that does 
that for you.
  
You can also use the function :
  
IDWK(arg)
  
Which will return the day of the week as an INTEGER and then instead of 
“Monday” you compare it to 1.
  
Probably other ways to do it but the ones above seem to be pretty straight 
forward.
  
 
  
Javier,
  
 
  
Javier Valencia, PE
  
O: 913-829-0888
  
H: 913-397-9605
  
C: 913-915-3137
  
 
  
From: [email protected] [mailto:[email protected]] On Behalf Of Karen Tellef
Sent: Wednesday, May 06, 2015 10:49 AM
To: RBASE-L Mailing List
Subject: [RBASE-L] - Previous business day function?
  
 
  
I'm happily using the DNW(.vdate) function with a loop to go out business days. 
 But now I also need a function that goes backwards to a PREVIOUS business day. 
 I don't see a function for that, right?  So I have to do the day of the week 
thing?

Karen
 

Reply via email to