Ciao a tutti sto cercando una funzione gia' pronta per tirare fuori tutti i lunedi' di un mese.
Qualche idea?
Grazie
Ciao a tutti sto cercando una funzione gia' pronta per tirare fuori tutti i lunedi' di un mese.
Qualche idea?
Grazie
Ti serve la funzione WeekDay() oppure la WeekDayName().
Per la tua funzione personalizzata, bisogna che ci dici che tipo di output vorresti che restituisse.
Andrebbe bene una stringa con i numeri dei lunedì divisi da virgola?
Ad esempio la funzione, per ottobre 2007 potrebbe restituire "1, 8, 15, 22, 29"
Inoltre dovresti decidere anche se vuoi questi dati partendo da un valore di tipo data oppure da due valori separati, mese ed anno.
codice:function getWeekDays(theMonth,theWeekDay) if theMonth > 0 and theMonth < 13 then for d = 1 to 31 tempDate = d & "/" & theMonth & "/" & datePart("yyyy",date()) if isDate(tempDate) then if datePart("w",tempDate) = theWeekDay then getWeekDays = getWeekDays & d & "," end if else exit for end if next end if if len(getWeekDays) > 0 then getWeekDays = left(getWeekDays,len(getWeekDays) - 1) end function response.write getWeekDays(10,3) ' per il mese di ottobre prendiamo i martedì
Aggiungo questo per maggior comprensione:Originariamente inviato da Mems
codice:function getWeekDays(theMonth,theWeekDay) if theMonth > 0 and theMonth < 13 then for d = 1 to 31 tempDate = d & "/" & theMonth & "/" & datePart("yyyy",date()) if isDate(tempDate) then if datePart("w",tempDate) = theWeekDay then getWeekDays = getWeekDays & d & "," end if else exit for end if next end if if len(getWeekDays) > 0 then getWeekDays = left(getWeekDays,len(getWeekDays) - 1) end function response.write getWeekDays(10,3) ' per il mese di ottobre prendiamo i martedì
codice:La funzione WeekDay restituisce i seguenti valori: Costante Valore Descrizione vbSunday 1 Domenica vbMonday 2 Lunedì vbTuesday 3 Martedì vbWednesday 4 Mercoledì vbThursday 5 Giovedì vbFriday 6 Venerdì vbSaturday 7 Sabato
PERFETTO raga, grazie mille.....![]()
un ultima domanda come faccio una volta ottenuta una stringa con tutti i lunedi' di ottobre, tipo la seguente: "1, 8, 15, 22, 29" a scomporre tutti i numeri ed a ricostruire le date tipo:
1/10/2007
8/10/2007
15/10/2007
22/10/2007
29/10/2007
Grazie in anticipo a tutti, ciao e buona giornata
codice:theMonth = 10 theDayOfWeek = 1 function getWeekDays(theMonth,theWeekDay) if theMonth > 0 and theMonth < 13 then for d = 1 to 31 tempDate = d & "/" & theMonth & "/" & datePart("yyyy",date()) if isDate(tempDate) then if datePart("w",tempDate) = theWeekDay then getWeekDays = getWeekDays & d & "," end if else exit for end if next end if if len(getWeekDays) > 0 then getWeekDays = left(getWeekDays,len(getWeekDays) - 1) end function stringDays = getWeekDays(theMonth,theDayOfWeek) if inStr(stringDays,",") > 0 then stringDays = split(stringDays,",") for i = 0 to uBound(stringDays) response.write stringDays(i) & "/" & theMonth & "/" & datePart("yyyy",date()) & " " next end if
simpatica ed utile questa funzione ...
grazie a tutti