Visualizzazione dei risultati da 1 a 10 su 10

Discussione: Problema con Date

  1. #1

    Problema con Date

    Ho un problema con questo script e spero che qualcuno possa aiutarmi.
    Il problema di questo script è che non seleziona il record dal db,sembra che il db converta la date nel formato mese/giorno/anno

    TodaysDate = Day(Date) & "/" & Month(Date) & "/" & Year(Date)
    TodaysDatePlus2 = DateAdd("m", 2, TodaysDate)

    'Create Possible Vehicle Model Recordsets
    Set rsVehiclesExpiring = Server.CreateObject("ADODB.Recordset")
    strSQL = "SELECT * FROM tblVehicles Where TerminationDate Between #" & TodaysDate & "# And #" & TodaysDatePlus2 & "#"
    'strSQL = "Select * from tblVehicles"
    rsVehiclesExpiring.Open strS


    le date vanno nel formato giorno/mese/anno
    Dade2 • Premium Windows Hosting • Microsoft Partner
    Server Dedicati • R1Soft daily backups • Dedicated Account Managers

  2. #2
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    Il db ragiona sempre all'inglese mm/dd/yyyy

    Roby

  3. #3
    Quindi come dovrei cambiare questo script?
    Scusate ma sono un newbie
    Dade2 • Premium Windows Hosting • Microsoft Partner
    Server Dedicati • R1Soft daily backups • Dedicated Account Managers

  4. #4
    Up
    Dade2 • Premium Windows Hosting • Microsoft Partner
    Server Dedicati • R1Soft daily backups • Dedicated Account Managers

  5. #5
    Inverti il posto di Day() con Month()

  6. #6
    Fatto:

    TodaysDate = Month(Date) & "/" & Day(Date) & "/" & Year(Date)
    TodaysDatePlus2 = DateAdd("m", 2, TodaysDate)

    'Create Possible Vehicle Model Recordsets
    Set rsVehiclesExpiring = Server.CreateObject("ADODB.Recordset")
    strSQL = "SELECT * FROM tblVehicles Where TerminationDate Between #" & TodaysDate & "# And #" & TodaysDatePlus2 & "#"
    'strSQL = "Select * from tblVehicles"
    rsVehiclesExpiring.Open strS

    Ma purtroppo non funziona
    Dade2 • Premium Windows Hosting • Microsoft Partner
    Server Dedicati • R1Soft daily backups • Dedicated Account Managers

  7. #7
    le devi invertire entrambe le date
    Ah, Jedis! I had no ideas! What can i do for you, honored Jedis?

    I'm not Jedi. I'm a guy with a lighsaber and a few questions.

  8. #8
    cioè dove dovrei invertire oltre TodaysDate ?

    Dade2 • Premium Windows Hosting • Microsoft Partner
    Server Dedicati • R1Soft daily backups • Dedicated Account Managers

  9. #9
    up
    Dade2 • Premium Windows Hosting • Microsoft Partner
    Server Dedicati • R1Soft daily backups • Dedicated Account Managers

  10. #10
    Ho modificato lo script in questo modo:

    Format(TodaysDate,"dd/mm/yyyy")
    TodaysDate = Day(Date) & "/" & Month(Date) & "/" & Year(Date)
    TodaysDatePlus2 = DateAdd("m", 2, TodaysDate)

    'Create Possible Vehicle Model Recordsets
    Set rsVehiclesExpiring = Server.CreateObject("ADODB.Recordset")
    strSQL = "SELECT * FROM tblVehicles Where TerminationDate Between #" &
    TodaysDate & "# And #" & TodaysDatePlus2 & "#"
    'strSQL = "Select * from tblVehicles"
    rsVehiclesExpiring.Open strS



    Aggiungendo il comando format()...ma mi da questo errore:

    Microsoft VBScript compilation error '800a0414'

    Cannot use parentheses when calling a Sub

    Format(TodaysDate,"dd/mm/yyyy")


    Credo sia una cosa banale...potete aiutarmi a risolverla?
    Grazie
    Dade2 • Premium Windows Hosting • Microsoft Partner
    Server Dedicati • R1Soft daily backups • Dedicated Account Managers

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.