Ciao a tutti,
sto riprendendo il codice di un calendario costruito non da me in ASP, collegato ad un database Access, e mi sono ritrovato ad avere dei problemi con le date;
per esempio, sembrerebbe che il codice le legga in formato gg/mm/aaaa, con
Session.LCID = 1040
ma il database access sembra che le restituisca solo in formato mm/gg/aaaa
Se io inserisco la data 01/02/2009, il calendario mi "attiva" il giorno 02 Gennaio
e se inserisco invece 02/01/2009 la data si riferisce al giorno 01 Febbraio...
fino a qui non ci dovrebbero esser problemi,
ma se inserisco la data del mio compleanno per esempio (28 giugno)
se la scrivo così: 28/06/2009, non mi da problemi e la riconosce
se invece la scrivo nell'altro metodo 06/28/2009 non la riconosce!
come posso sistemare questo casino???
Grazie a tutti
questo è il codice del calendario:
<%
TableWidth = 500
BgColor = "#cccccc"
CellColor = "#fdf5e6"
dbName = "database_eventi.mdb"
Conn= "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & Server.MapPath(dbName)
ViewDayImage = "goto.gif"
EditImage = "<font face=WingDings>" & chr(50) & "</font>"
DeleteImage = "<font face=WingDings>" & chr(251) & "</font>"
ToTopImage = "<font face=WingDings>" & chr(241) & "</font>"
'*ToTopimage = "<img border=0 src=up.gif>"
'# UserName: admin
'# Password: admin
'# You can manually change this in the database
'Session.LCID = 1033
'Data in inglese
Session.LCID = 1040
'Data in italiano
%>
<%
'************************************************
'***** FUNCTIONS *********
'************************************************
Sub DisplayCalendar(mMonth, yYear)
dDay = DateSerial(yYear,mMonth,1)
mMonth = Month(dDay)
yYear = Year(dDay)
FirstDayOfMonth = Weekday(dDay)
'## Display the Top of Calendar ##
CALL DisplayCalendarTop(dDay)
'## Start Displaying the Actual Calendar ##
Response.Write "<Table Align=center width=" & TableWidth & " CellPadding=3 CellSpacing=1 Border=1 BgColor=" & BgColor & ">" & vbCrlf
Response.Write "<TR Valign=Top Align=Center BgColor=" & bgcolor & ">" & vbCrlf
For i = vbSunday To vbSaturday
Response.Write "<TD><Font Size='-2'>" & left(WeekDayName(i), 3) & "</Font></TD>" & vbCrlf
Next
Response.Write "</TR>" & vbCrlf
'## Set dDay to the First day of the month ##
dDay = DateSerial(yYear,mMonth,1)
FOR j=1 to 6
Response.Write "<TR>" & vbCrlf
FOR i=vbSunday to vbSaturday
CellStr="<Font size=-3></Font>"
Color=cellcolor
If WeekDay(dDay) = i and Month(dDay) = mMonth then
'## Set Color if Current Day
if (Day(dDay) = Day(now)) and (Month(dDay) = Month(now)) and (Year(dDay) = Year(now)) then Color="#ffffff"
CellStr = "<Font size=-2>" & Day(dDay) & "</Font>
"
'## Get the Memo Field out of Database for current Date
Memo = GetCellData(dDay)
IF Memo <> "" then
'## Format Cell String if there is a Memo ##
CellStr ="<Font size=-2>" & Day(dDay) & "</Font>
" & "<a href=#" & dDay & ">[img] & ViewDayImage & [/img]</a>"
'## Save Calendar Details to Print After the Calendar is Displayed ##
Details = Details & "<Table Align=center width=" & TableWidth & " cellspacing=2 cellpadding=3 border=0>" & vbCrlf
Details = Details & "<TR>" & vbCrlf
Details = Details & " <TD width=" & TableWidth-10 & " bgcolor='" & Bgcolor & "'>" & vbCrlf
Details = Details & " <a name='" & dDay & "'><Font Size=-1>" & Ucase(WeekDayName(weekday(dDay))) & " , " & Day(dDay) & " " & Ucase(MonthName(Month(dDay))) & " " & Year(dDay) & "</Font>" & vbCrlf
Details = Details & " </TD>" & vbCrlf
Details = Details & " <TD Align=right bgcolor='" & BgColor & "'>" & vbCrlf
Details = Details & "" & EditImage & ""
Details = Details & "" & DeleteImage & ""
Details = Details & "<a href=#top>" & ToTopImage & "</a>"
Details = Details & " </TD>" & vbCrlf
Details = Details & "</TR>" & vbCrlf
Details = Details & "</Table>" & vbCrlf
Details = Details & "<Table Align=center width=" & TableWidth & " cellspacing=2 cellpadding=3 border=0>" & vbCrlf
Details = Details & "<TR>" & vbCrlf
Details = Details & " <TD bgcolor='" & color & "'>" & vbCrlf
Details = Details & " <PRE><Font Face=arial>" & Memo & "</Font></PRE>" & vbCrlf
Details = Details & " </TD>" & vbCrlf
Details = Details & "</TR>" & vbCrlf
Details = Details & "</Table>" & vbCrlf
'## End Calendar Details ##
End If
'## Get the Next Day
dDay = DateAdd("d",1,dDay)
End If
Response.Write "<TD vAlign=top align=left BgColor='" & Color & "'>" & CellStr & "</TD>" & vbCrlf
NEXT '## FOR i=vbSunday to vbSaturday ##
Response.Write "</TR>" & vbCrlf
NEXT '## For j=1 to 6 ##
Response.Write "</Table>" & vbCrlf
'## Display the Months at the bottom of the calendar ##
CALL DisplayMonths()
'## Display the Calendar Details ##
Response.write "
" & Details & "
"
For i=1 to 50
Response.write "
"
Next
End Sub
'************************************************
'************************************************
Sub DisplayCalendarTop(dDay)
Title = MonthName(month(dDay)) & " " & year(dDay)
pPREVIOUS = dateadd("m",-1, dDay)
nNEXT = dateadd("m",1,dDay)
Response.Write "<a name=top><TABLE Align=center CELLPADDING=0 CELLSPACING=0 WIDTH=" & TableWidth & " BORDER=1>" & vbCrlf
Response.Write "<TR VALIGN=MIDDLE ALIGN=CENTER>" & vbCrlf
Response.Write "<TD BgColor='" & BgColor & "' ALIGN=center>" & vbCrlf
Response.Write "<font FACE=WingDings>" & chr(239) & "</font>" & vbCrlf
Response.Write "</TD>" & vbCrlf
Response.Write "<TD BgColor='" & BgColor & "' ALIGN=center>" & vbCrlf
Response.Write "" & Title & "" & vbCrlf
Response.Write "</TD>" & vbCrlf
Response.Write "<TD BgColor='" & BgColor & "' ALIGN=center>" & vbCrlf
Response.Write "<font FACE=WingDings>" & chr(240) & "</font>" & vbCrlf
Response.Write "</TD>" & vbCrlf
Response.Write "</TR>" & vbCrlf
Response.Write "</TABLE>" & vbCrlf
End Sub
'************************************************
'************************************************
Sub DisplayMonths()
Response.Write "<TABLE Align=center CELLPADDING=0 CELLSPACING=0 WIDTH=" & TableWidth & " BORDER=1 BORDERCOLORLIGHT=#FFFFFF>" & vbCrlf
Response.Write "<TR VALIGN=MIDDLE ALIGN=CENTER>" & vbCrlf
Response.Write "<TD BgColor='" & "#cccccc" & "' ALIGN=center>" & vbCrlf
Response.write "<Font size=-2>"
Response.Write "Gennaio" & vbCrlf
Response.Write "Febbraio" & vbCrlf
Response.Write "Marzo" & vbCrlf
Response.Write "Aprile" & vbCrlf
Response.Write "Maggio" & vbCrlf
Response.Write "Giugno" & vbCrlf
Response.Write "
"
Response.Write "Luglio" & vbCrlf
Response.Write "Agosto" & vbCrlf
Response.Write "Settembre" & vbCrlf
Response.Write "Ottobre" & vbCrlf
Response.Write "Novembre" & vbCrlf
Response.Write "Dicembre" & vbCrlf
Response.Write "</Font>" & vbCrlf
Response.Write "</TD>" & vbCrlf
Response.Write "</TR></TABLE>" & vbCrlf & vbCrlf
Response.Write "<Center>Vedi tutto l'anno</Font></Center>"
Response.Write "<Center>Ricerca evento</Font></Center>"
End Sub
'************************************************
'************************************************
Function GetCellData(dDay)
Set rs = Server.CreateObject("ADODB.Recordset")
sSQL = "Select * from CalendarInfo where Date=#" & dDay & "#"
rs.open sSQL, Conn,3,3
GetCellData = ""
if rs.recordcount > 0 then GetCellData=rs("memo")
rs.close
Set rs = nothing
End Function
'************************************************
'************************************************
Sub DisplaySmallCalendar(mMonth, yYear)
Title = "<a href=calendar.asp?month=" & mMonth & "&year=" & yYear & ">" & MonthName(mMonth) & " " & yYear & "</a>"
dDay = DateSerial(yYear,mMonth,1)
mMonth = Month(dDay)
yYear = Year(dDay)
FirstDayOfMonth = Weekday(dDay)
Response.Write "<TABLE Align=center width=150 CELLPADDING=0 CELLSPACING=0 BORDER=1>" & vbCrlf
Response.Write "<TR VALIGN=MIDDLE ALIGN=CENTER>" & vbCrlf
Response.Write "<TD BgColor='" & BgColor & "' ALIGN=center>" & vbCrlf
Response.Write "<font size=-2>" & Title & "</font>" & vbCrlf
Response.Write "</TD>" & vbCrlf
Response.Write "</TR>" & vbCrlf
Response.Write "</TABLE>" & vbCrlf
'## Start Displaying the Actual Calendar ##
Response.Write "<Table width=150 Align=center CellPadding=3 CellSpacing=1 Border=1 BgColor='" & BgColor & "'>" & vbCrlf
Response.Write "<TR Valign=Top Align=Center BgColor='" & bgcolor & "'>" & vbCrlf
For i = vbSunday To vbSaturday
Response.Write "<TD><Font Size='-3'>" & left(WeekDayName(i), 1) & "</Font></TD>" & vbCrlf
Next
Response.Write "</TR>" & vbCrlf
'## Set dDay to the First day of the month ##
dDay = DateSerial(yYear,mMonth,1)
FOR j=1 to 6
Response.Write "<TR>" & vbCrlf
FOR i=vbSunday to vbSaturday
CellStr="<Font size=-3></Font>"
Color=cellcolor
If WeekDay(dDay) = i and Month(dDay) = mMonth then
'## Set Color if Current Day
if (Day(dDay) = Day(now)) and (Month(dDay) = Month(now)) and (Year(dDay) = Year(now)) then Color="#00ff00"
CellStr = "<Font size=-3>" & Day(dDay) & "</Font>"
'## Get the Next Day
dDay = DateAdd("d",1,dDay)
End If
Response.Write "<TD vAlign=top align=left BgColor='" & Color & "'>" & CellStr & "</TD>" & vbCrlf
NEXT '## FOR i=vbSunday to vbSaturday ##
Response.Write "</TR>" & vbCrlf
NEXT '## For j=1 to 6 ##
Response.Write "</Table>" & vbCrlf
End Sub
'************************************************
'************************************************
Function CheckPwd(username,password)
Set rs = Server.CreateObject("ADODB.Recordset")
sSQL = "Select * from Passwords where username='" & username & "' and password='" & password & "'"
rs.open sSQL, Conn, 3, 3
CheckPwd = False
if rs.recordcount > 0 then CheckPwd = True
rs.close
set rs = nothing
End Function
'************************************************
'************************************************
%>

Rispondi quotando