Visualizzazione dei risultati da 1 a 3 su 3
  1. #1
    Utente di HTML.it L'avatar di diegoctn
    Registrato dal
    May 2001
    Messaggi
    2,118

    Problema su select ultima settimana

    Ragazzi se voglio vedere solo l'ultima settimana....

    codice:
    sql="Select * from principale where cognomepaz like '%"&cercax&"%' and dtt > date()-7  order by dtt asc;"
    essendo il campo dtt il campo del giorno....non dovrebe essere così?

  2. #2
    Utente di HTML.it L'avatar di fraude
    Registrato dal
    Feb 2004
    Messaggi
    2,870
    L'ultima settimana del mese ?

    Usa questa funzione:

    ...:
    codice:
    monthLengths = Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
     
    Function getLastMonthDay(m, y)  ' numero di giorni nel mese e anno corrente
      getLastMonthDay = monthLengths(m - 1)
      If m = 2 And (y Mod 4) = 0 And ((y Mod 100) <> 0 Or (y Mod 400) = 0) Then getLastMonthDay = 29
    End Function
     
     
    ' determina se il numero della settimana "rientra indietro" dal mese successivo (settimana numero 1)
    Function checkForFoldBack(dt, monthWeek, off)
      top = getLastMonthDay(Month(dt), Year(dt))
      lastMonday = (Int((top - off) / 7) * 7) + off
     
      If Day(dt) >= lastMonday And (top - lastMonday) < 3 Then monthWeek = 1
      checkForFoldBack = monthWeek
    End Function
     
     
    Function MonthWeek(dt, flFoldBack)  ' determina il numero della settimana del mese corrente
      wd = DatePart("w", Eval("#" & Month(dt) & "/1/" & Year(dt) & "#"), 2)
     
      If wd <= 4 Then
        mw = Int((Day(dt) - (2 - wd)) / 7) + 1
        If flFoldBack Then mw = checkForFoldBack(dt, mw, 2 - wd)
      Else
        mw = Int((Day(dt) - (9 - wd)) / 7)
     
        If mw < 0 Then
          yr = Year(dt)
          mt = Month(dt) - 1
     
          If mt < 1 Then
            mt = 12
            yr = yr - 1
          End If
     
          mw = MonthWeek(Eval("#" & mt & "/28/" & yr & "#"), False)
        Else
          mw = mw + 1
          If flFoldBack Then mw = checkForFoldBack(dt, mw, 9 - wd)
        End If
      End If
     
      MonthWeek = mw
    End Function
    si può ottenere il numero della settimana del mese corrente così:
    codice:
    NumeroSettimanaMeseCorrente = MonthWeek(dt, True)

  3. #3
    Utente di HTML.it L'avatar di diegoctn
    Registrato dal
    May 2001
    Messaggi
    2,118
    Ti ringrazio ma precisamente a me basterebbe che i valori della query siano quelli dell'ultima settimana. Quindi:
    codice:
    basedata=date()-7
    ................
    ................
    sql="Select * from principale where cognome like '%"&cercax&"%' and dtt <= '"&basedata&"'  order by dtt asc;"
    Solo che sbaglio la sintassi.

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.