fanlinux90
Programmer
Between the dates 11/28/2023 and 12/02/2022 I know how many days there are. DATE(2023, 11, 28) - DATE(2022, 12, 02), how can I calculate how many Fridays, Saturdays, and Sundays there are between those two dates?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
FUNCTION WORKDAYS
PARAMETERS m.DATE1,m.DATE2
PRIVATE m.NUMDAYS,m.DATE1,m.DATE2,m.TMPDATE,m.IDATE,m.COUNT
PRIVATE m.INIBITDAYS
m.INHIBITDAYS = "FRI;SAT;SUN;"
IF EMPTY(m.DATE1) .OR. EMPTY(m.DATE2)
m.NUMDAYS = 0
ELSE
IF m.DATE2 < m.DATE1
m.TMPDATE = m.DATE1
m.DATE1 = m.DATE2
m.DATE2 = m.TMPDATE
ELSE
m.TMPDATE = CTOD("//")
ENDIF
m.IDATE = m.DATE1
m.COUNT = 0
DO WHILE m.IDATE < m.DATE2
IF !UPPER(LEFT(CDOW(m.IDATE),3))+";"$m.INHIBITDAYS
m.COUNT = m.COUNT +1
ENDIF
m.IDATE = m.IDATE +1
ENDDO
m.NUMDAYS = m.COUNT
ENDIF
RETURN(m.NUMDAYS)
LPARAMETERS tdDateStart, tdDateEnd
LOCAL liWEDays, liWorkDays
liWEDays = 0
liWorkDays = 0
IF VARTYPE(tdDateStart) = "D" AND VARTYPE(tdDateEnd) = "D" AND tdDateStart < tdDateEnd
liWEDays = 0
FOR i = 0 TO tdDateEnd - tdDateStart
IF CDOW(tdDateStart + i) = "Friday" OR CDOW(tdDateStart + i) = "Saturday" OR CDOW(tdDateStart + i) = "Sunday"
liWEDays = liWEDays + 1
ENDIF
ENDFOR
liWorkDays = tdDateEnd - tdDateStart - liWEDays
WAIT WINDOW + "Workdays: " + TRANSFORM(liWorkDays) + " - " + "WE Days: " + TRANSFORM(liWEDays)
ELSE
= MESSAGEBOX("Wrong parameters", 16, "Checking parameters")
ENDIF
RETURN liWEDays
I'm not sure that's exactly what you wanted to say. But lets say, you most often get something here that lets you keep going. Not only on tek-tips.Steve-vfp9user said:if eventually there is no response or resolution, then you'll get your answer