Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How many weeks in a month
Message
From
06/11/2007 12:21:32
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01266837
Message ID:
01267025
Views:
11
Very nice Sergey!
Thank you once again.

Just added a bit of tinsel:
LPARAMETERS pvParm1 , piYear , piFDOW
LOCAL liWeeksPerMonth AS INTEGER
LOCAL liFDOW AS INTEGER
LOCAL liMonth AS INTEGER
LOCAL liYear AS INTEGER
LOCAL liPcount AS INTEGER

liPcount = PCOUNT()

DO CASE
  CASE INLIST(VARTYPE(pvParm1),[D],[T])
    liMonth = MONTH(pvParm1)
    liYear  = YEAR(pvParm1)

  CASE liPcount >= 2 AND VARTYPE(pvParm1) = [N] AND VARTYPE(piYear) = [N] AND BETWEEN(pvParm1,1,12) AND BETWEEN(piYear,1,9999)
    liMonth = pvParm1
    liYear  = piYear

  OTHERWISE
    ERROR 11
    RETURN

ENDCASE

IF liPcount = 3 AND VARTYPE(piFDOW) = [N]
  IF BETWEEN(piFDOW,1,7)
    liFDOW = piFDOW
  ELSE
    ERROR 11
    RETURN
  ENDIF
ELSE
  liFDOW = SET("FDOW")
ENDIF

ldFirstOfMonth = DATE(liYear, liMonth, 1)

liWeeksPerMonth = MOD(WEEK(GOMONTH(ldFirstOfMonth,1),0,liFDOW)+52 - WEEK(ldFirstOfMonth,0,liFDOW), 52)
RETURN liWeeksPerMonth
Let me know if I created any errors.
Thank you,
- Frank
Previous
Reply
Map
View

Click here to load this message in the networking platform