Visualizzazione dei risultati da 1 a 9 su 9
  1. #1
    Utente di HTML.it
    Registrato dal
    Nov 2005
    Messaggi
    395

    funzione trovare tutti i lunedi' di un mese

    Ciao a tutti sto cercando una funzione gia' pronta per tirare fuori tutti i lunedi' di un mese.
    Qualche idea?
    Grazie

  2. #2
    Utente di HTML.it L'avatar di longline
    Registrato dal
    Sep 2001
    Messaggi
    5,363
    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"

  3. #3
    Utente di HTML.it L'avatar di longline
    Registrato dal
    Sep 2001
    Messaggi
    5,363
    Inoltre dovresti decidere anche se vuoi questi dati partendo da un valore di tipo data oppure da due valori separati, mese ed anno.

  4. #4
    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ì

  5. #5
    Utente di HTML.it L'avatar di longline
    Registrato dal
    Sep 2001
    Messaggi
    5,363
    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ì
    Aggiungo questo per maggior comprensione:
    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

  6. #6
    Utente di HTML.it
    Registrato dal
    Nov 2005
    Messaggi
    395
    PERFETTO raga, grazie mille.....

  7. #7
    Utente di HTML.it
    Registrato dal
    Nov 2005
    Messaggi
    395
    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

  8. #8
    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

  9. #9
    Utente di HTML.it L'avatar di EmTmE
    Registrato dal
    Jun 2001
    Messaggi
    333
    simpatica ed utile questa funzione ...
    grazie a tutti

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.