Ir para conteúdo

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Dell

Calendario em asp

Recommended Posts

Tenho um calendario feito em asp e preciso fazer uma alteração. O calendario é simples mostra 2 semanas do mês atual e 2 semanas do próximo mês.

Eu preciso que o calendário mostre 2 semanas do mês passado e duas do mês atual.

É exatamente como esse porém mostrando 2 semanas do mês que passou.

Neste calendário será mostrado Maio e Junho, eu preciso mostrar Abril e Maio. Mas não sei como fazer isso.

Esse é o fonte:

 

 

<% 
 
   Dim gsMonthNamePre
   Dim gsMonthNamePost
   Dim gsDayNamePre
   Dim gsDayNamePost
   Dim gsAnyDayPre
   Dim gsAnyDayPost
   Dim gsTodayPre
   Dim gsTodayPost
   Dim gdToday
   Dim giAbbreviateMonth
   Dim giAbbreviateDay
   Dim gdFirstDay
   Dim gdCurrentDay
   Dim giCurrentMonth
   Dim giLastMonth
   Dim giDayOfTheWeek
   Dim gsEmbeddedCode
   Dim gsPageHeader
   Dim gsPageFooter


   giAbbreviateMonth = False
   giAbbreviateDay = True
   gsMonthNamePre = "<td colspan=""7"" bgcolor=""#ffffff""><p align=""center"">"
   gsMonthNamePost = "</td>"
   gsDayNamePre = "<td width=""14%""><FONT SIZE=""-1""><em> "
   gsDayNamePost = " </em></FONT></td>"
   gsAnyDayPre = "<td width=""14%""><FONT SIZE=""-1"">"
   gsAnyDayPost = "</FONT></td>"
   gsTodayPre = "<td width=""14%"" bgcolor=""#a0ffff"" ><b><FONT SIZE=""-1"">"
   gsTodayPost = "</FONT></b></td>"
   gsEmptyCell = "<td width=""14%""> </td>"


   gdToday = Now  
   gdFirstDay = gdToday
   Do While DatePart("w", gdFirstDay) > 1
	   gdFirstDay = DateAdd("d", -1, gdFirstDay)
   Loop
   gdCurrentDay = gdFirstDay
   giCurrentMonth = Month(gdCurrentDay)
   giLastMonth = 0

   iWeeks = 4 
   Response.Write("<table border=""1"" cellspacing=""0"" cellpadding=""0"">")
   Do While iWeeks > 0 
	  If giLastMonth <> giCurrentMonth Then 
		 giLastMonth = giCurrentMonth 
		 Response.Write("<tr>")
		 Response.Write( gsMonthNamePre & MonthName(giCurrentMonth, giAbbreviateMonth) & " " &  DatePart("yyyy", gdCurrentDay) & gsMonthNamePost )
		 Response.Write("</tr><tr>")
		 For iDayOfWeek = 1 to 7 
			Response.Write(gsDayNamePre & WeekDayName(iDayOfWeek, giAbbreviateDay) & gsDayNamePost)
		 Next
		 Response.Write("</tr>")
	  End If
	  Response.Write("<tr>")
	  For iDayOfWeek = 1 to 7 
		 If giLastMonth = giCurrentMonth Then 
			giDayOfTheWeek = DatePart("w", gdCurrentDay) 
			If iDayOfWeek = giDayOfTheWeek Then 
			   If gdCurrentDay = gdToday Then 
				  Response.Write(gsTodayPre & DatePart("d", gdCurrentDay) & gsTodayPost)
			   Else
				  Response.Write(gsAnyDayPre & DatePart("d", gdCurrentDay) & gsAnyDayPost)
			   End If
			   gdCurrentDay = DateAdd("d", 1, gdCurrentDay) 
			   giCurrentMonth = Month(gdCurrentDay) 
			Else 
			   Response.Write(gsEmptyCell)
			End If
		 Else
			Response.Write(gsEmptyCell)
		 End If
	  Next
	  Response.Write("</tr>")
	  iWeeks = iWeeks - 1 
   Loop
   Response.Write("</table>")

%>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Bom essa função abaixo te traz o último dia do mês anterior.... com ela você pode calcular as últimas semanas do mês que passou

 

DateAdd("d", -1, FormatDateTime( DateAdd("m", -1, FormatDateTime("01/"& month(now) &"/"& year(now)) ), 0) )

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.