Microsoft KB Archive/100431

From BetaArchive Wiki
< Microsoft KB Archive
Revision as of 19:13, 12 August 2020 by X010 (talk | contribs) (X010 moved page Microsoft KB Archive/Q100431 to Microsoft KB Archive/100431 without leaving a redirect: Text replacement - "Microsoft KB Archive/Q" to "Microsoft KB Archive/")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

INF: User-Defined Function for Computing the Week of the Year

PSS ID Number: Q100431 Article last modified on 08-31-1993

2.00 2.50 2.50a | 2.50 2.50a MS-DOS | WINDOWS

The information in this article applies to:
- Microsoft FoxPro for MS-DOS, versions 2.0 2.5 and 2.5a - Microsoft FoxPro for Windows, versions 2.5 and 2.5a

Summary: To compute the week of the year (1 through 52), use the following user-defined function (UDF): SET TALK OFF mdate = { / / } @5,15 SAY “Enter a date:” GET mdate READ weeknum = getWeek(mdate) wait window str(weeknum) ********************************************************************* * This UDF builds a date based on the format 01/01/year entered. * It subtracts that day minus 1 from the passed date, and divides * by 7.02 (the number of days in a week). It then adjusts the answer * to a fixed number, and returns the answer. Parameters: startDate - Date in question. Variables: firstDay - The first day of the startDate year. * lastDay - The last day of the previous year. * wNum - The number of days from 01/01/year entered * to the date entered. ********************************************************************* FUNCTION getWeek PARAMETERS startDate firstDay = “01/01/” + str(year(startDate),4,0) LastDay = ctod(firstDay)-1 wNum = (startDate - LastDay) / 7.02 wNum = ROUND(wNum,0) RETURN(wNum)

Additional reference words: 2.00 2.50 2.50a Copyright Microsoft Corporation 1993.