Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to return the first day of a given week?
Message
De
11/09/1998 06:53:09
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
11/09/1998 06:09:38
Mark Hall
Independent Developer & Voip Specialist
Keston, Kent, Royaume Uni
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00135392
Message ID:
00135413
Vues:
8
>>Hi all.
>>The question says itself!
>>
>>Has anybody a solution?
>>
>>
>>Best regards
>>
>>Per Simmersholm
>
>Well, the question is open to interpretation. But, if the question means how can I find the first day of the week for a given week number in the year, then try this:
>
>*-- Start
>FUNCTION Day1
>PARAMETERS lnWeek
>LOCAL lnThisWeek, ldTodayInWeek, ldFirstDayInWeek
>
>lcThisWeek = WEEK( DATE())
>
>ldTodayInWeek = DATE() - ((lcThisWeek - lnWeek) * 7)
>
>*-- Now to get first day of week
>ldFirstDayInWeek = ldTodayInWeek - ( DOW( ldTodayInWeek) - SET("FDOW"))
>
>RETURN ldFirstDayInWeek
>*-- End
>
>Which will work with the current settings of FWEEK and FDOW
Then Mark,
For any given week number as a parameter it could be :
function xFDOW
lparameters tnWeekNumber, tnDOWSet
if parameters()<2
  tnDOWSet = 0
endif
local lnOldDateSet,ldJan1st,ldWeek,ldFdow
lnOldDateSet = set("date",1)
set date to mdy
ldJan1st = ctod("1/1/"+str(year(date()),4))
ldWeek = (tnWeekNumber - 1) * 7 + ldJan1st
ldFdow = ldWeek - (dow(ldWeek,tnDOWSet)) + 1
do case
  case lnOldDateSet = 1
    set date to dmy
  case lnOldDateSet = 2
    set date to ymd
endcase
return ldFdow
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform