Jan: If you're counting work days between 2 dates, and not using columns in a table like Razzak's example, I use this. vBDate is the first date to check, vEDate is the last date:
SET VAR vDays = (.vEDate - .vBDate) SET VAR vCount INT = 0, vLoop INT = 0 WHILE vLoop <= .vDays THEN SET VAR vTestDate = (.vBDdate + .vLoop) IF (IDWK(.vTestDate)) BETWEEN 1 AND 5 THEN SET VAR vCount = (.vCount + 1) ENDIF SET VAR vLoop = (.vLoop + 1) ENDWHILE Karen -----Original Message----- From: jan johansen <[email protected]> To: [email protected] Sent: Tue, Mar 16, 2021 6:40 am Subject: Re: [RBASE-L] - Date calculation Razzak, Thanks! You're up early. I know, I know... the sun never sets on R:Base! Jan From: "A. Razzak Memon" <[email protected]> To: [email protected] Date: Tue, 16 Mar 2021 07:25:26 -0400 Subject: Re: [RBASE-L] - Date calculation Jan, Here's how ... Use the IDWK function to exclude the 6th and 7th (Saturday and Sunday) day of the Week. -- IDWK returns the day of the week where Monday is 1. -- Example 01 SELECT * FROM tablename WHERE (IDWK(datecolumn)) NOT IN (6,7) -- Example 02 SELECT * FROM tablename WHERE (IDWK(datetimecolumn)) NOT IN (6,7) That's all there is to it! Have fun. Very Best R:egards, Razzak At 07:15 AM 3/16/2021, jan johansen wrote: >Group, > >Anyone got a good date algorithm that ignores weekends? Or in other >words, only counts workdays? > >Jan -- For group guidelines, visit http://www.rbase.com/support/usersgroup_guidelines.php --- You received this message because you are subscribed to the Google Groups "RBASE-L" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rbase-l/0Lm2Pn-1lvSWt3yqH-00Zixe%40mrelay.perfora.net. -- For group guidelines, visit http://www.rbase.com/support/usersgroup_guidelines.php --- You received this message because you are subscribed to the Google Groups "RBASE-L" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rbase-l/WC20210316114033.39000A%40jjcalibrations.com. -- For group guidelines, visit http://www.rbase.com/support/usersgroup_guidelines.php --- You received this message because you are subscribed to the Google Groups "RBASE-L" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rbase-l/251168454.1172113.1615903806244%40mail.yahoo.com.

