Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Determining the start and end dates of a given week
Message
 
À
08/12/2003 11:53:32
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00856775
Message ID:
00856876
Vues:
19
Fernando,

Then probably the week() function should be replaced by:

lddate={^2003-12-29}
?IIF(MONTH(lddate)=12 AND WEEK(lddate)=1,wEEK(lddate-7)+1,WEEK(lddate))

>Hi Yuri,
>
>I'm using the Week() function as: nWeekNumber = Week (dGivenDate, 1, 1).
>
>It seems to be working ok. Just checking a bit deeper because there are *two" weeks numbered *1* in 2003. One starts december 29, 2002 and ends january 4, 2003. The *other* starts december 28, 2003 and ends january 3, 2004.
>
>So it seems to me that we must specify not just the week number and the year but the month, as well.
>
>Regards,
>
>Fernando
>
>>See if it is what you need. Details may vary depending on how the
>>
>>WEEK(dExpression | tExpression [, nFirstWeek] [, nFirstDayOfWeek])
>>
>>is calculated.
>>
>>
>>nWeekNumber=50
>>nYear=2003
>>
>>ld=date(nYear,1,1)+ (nWeekNumber-1)*7
>>?"First Day: ",ld-DOW(ld)+1
>>?"Last Day: ",ld+7-DOW(ld)
>>
>>
>>>Hi Rhodri, thanks for replying!
>>>
>>>Sorry, think I couldn't express myself correctly. When I asked:
>>>
>>>"How can I determine the dates of the first and the last days in a week, given the week number, the year and the month where it occurs?"
>>>
>>>I wanted to mean that, having a specific week, identified by its number (please see Week() function), like 1, 2,..., 52, and knowing in what month it falled (say week number 50 of december, 2003) what dates corresponded to the first (sunday) and last (saturday) days of that specific week.
>>>
>>>In that case I would have, for example, two functions with 3 parameters like:
>>>
>>>dStartDate = FirstDateOfWeek (nWeekNumber, nYear, nMonth)
>>>
>>>and
>>>
>>>dEndDate   = LastDateOfWeek  (nWeekNumber, nYear, nMonth)
>>>
>>>
>>>Hope now I was more clear <s>
>>>
>>>Regards,
>>>
>>>Fernando
>>>
>>>
>>>>This can be achieved fairly easily using VFP's DOW() function
>>>>
>>>>?Date()-Dow(Date())+1 && beginning of this week
>>>>?Date()+7-Dow(Date()) && end of this week
>>>>
>>>>Function StartWeek
>>>>Lparameters tdDate
>>>>Return tdDate - Dow(tdDate) + 1
>>>>
>>>>Function EndWeek
>>>>Lparameters tdDate
>>>>Return tdDate + 7 - Dow(tdDate)
>>>>
>>>>Rhodri
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform