Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Dates of first and last day of week
Message
 
To
05/05/2007 14:00:06
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01222747
Message ID:
01222748
Views:
14
>Hi all.,
>Anybody has function/solution which returns date for first and last of any week in year ?
>TIA,
>Gojko
CLEAR
? GetFirstDayOfWeek(19, 2006)
? GetLastDayOfWeek(19, 2006)

FUNCTION GetFirstDayOfWeek(lnWeekNumber, lnYear)
    IF VARTYPE(lnYear) # [N]
       lnYear = YEAR(DATE())
    ENDIF
RETURN DATE(lnYear,1,1)+(lnWeekNumber-1)*7 - DOW(DATE(lnYear,1,1),2)+1

FUNCTION GetLastDayOfWeek(lnWeekNumber, lnYear)
RETURN GetFirstDayOfWeek(lnWeekNumber, lnYear)+6
Not properly tested, and it is related to what you mean 1 week in the year and also what is first day of the week. These functions are based on 1/1/year is the first week in the year and Monday is the first day of the week.
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform