Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Preciso de um script que verifique se a data de hoje é maior que a data gravada no banco mysql.
Tipo se a data de hoje for maior que 3 dias, avisar se está no prazo ou atrazado.
Arrumei este código más não deu certo.
E isso será numa listagem tipo
nome data
---------------------------
Paulo 22/10/2008
Pedro atrasado (pois passou de 3 dias)
Manuel 21/10/2008
e assim vai.
Agradeço a quem puder me ajudar
Dim data, varColor, varData, varResposta
varData = rs("datalog")
data=date()-Day(4) 'data= data atual - 4 dias (pois ele conta o dia de hj por isso é 4 senao seria 3
if varData > data then
varResposta = "no prazo"
else
varResposta = "atrasado"
end if
Não funcionou não.
Más valeu por responder.
Estou colocando meu código completo aqui.
<!--#include file="../Connections/bib_conexao.asp"-->
Dim Conexao, rsSelect, sqlSelect, rs, strSQL, rsProd, rsSab, varCodigo
varCodigo = Request.querystring("cod")
'select no banco
sqlSelect = "SELECT * FROM rm WHERE cod_rm = " & varCodigo
'abre a conexao
Call abre_conexao
'executa a instrução SQL
Set rs=Conexao.Execute(sqlSelect)
Dim varColor, varData, varR
varData = rs("sac_data_lab")
if DateDiff("d",Date,varData) >=3 then
varR = "Atrasado"
else
varR = "No Prazo"
end if
é só você destrinchar a data e pegar o dia e diminuir, ai você joga no sql para comparar
O campo no Banco de dados é do tipo date ou datetime? Outra coisa: talvez ao invés de Date você precisa colocar Date(now).
Vale também a dica do Ted k, use if day(now) >= day(varData)+3
Valeu pela ajuda.
Realmente assim funciona, más aqui está pegando apenas o dia.
preciso que verifique a data completa. tipo 23/10/2008.
porque senão quando day(now) for dia 1/11/2003 e day(varData) estiver dia 30, irá constar como atraso.
Tem que verificar com dia mes anao
Eu tentei colocar como date no lugar de day, más dá erro
varData = rs("sac_data_lab")
if day(now) >= day(varData)+3 then
varR = "Atrasado"
else
varR = "No Prazo"
end if
Então agora ficou fácil!
if day(now) >= day(varData) and (month(varData = month(now) and year(varData = year(now)) then
varR = "Atrasado"
else
varR = "No Prazo"
end if
Tenta assim
tá dando erro.
Erro de compilação do Microsoft VBScript (0x800A03EE)
')' esperado
if day(now) >= day(varData) and (month(varData = month(now) and year(varData = year(now)) then
eu tirei o ')' más não adiantou.
E outra coisa, neste código não tá verificando se a data do banco é maior que 3
Tá quase lá. rs
É mesmo, foi mal. Faltaram os parenteses do varData
if day(now) >= day(varData)+3 and (month(varData) = month(now) and year(varData) = year(now)) then
varR = "Atrasado"
else
varR = "No Prazo"
end if
se não der tenta assim
dim diaVar
diaVar = day(varData)+3 'guardei numa variável para evitar problemas, tenta sem usar variável tb
if day(now) >= diaVar and month(varData) = month(now) and year(varData) = year(now) then
varR = "Atrasado"
else
varR = "No Prazo"
end if
Puts, ainda não deu certo acredito por causa disso:
Eu fiz um teste, coloquei no banco com data de 25/10/2008 e a data no servidor 1/11/2008, aí ficou tudo no prazo.
Neste caso aqui o sistema tá verificando se o dia é maior ou igual a 3 e não o mês e ano. Não está comparando a data completa.
Se virar o mês, tipo se hoje for dia 1/11/2008 e eu tiver um cadastro no banco com data de 29/10/2008, o
sistema irá me informar que está no prazo
No caso o sistema precisa verificar se a data do cadastro incluindo mês e ano realmente é maior que 3 dias
diaVar = day(varData)+3
if day(now) >= diaVar and month(varData) = month(now) and year(varData) = year(now) then
Esse caso meu é difícil.
Mas valeu mesmo por me ajudar. Tá quase lá. rs
Talvez você possa separar a condição, ela tá longa demais. Faça um função comparando se o mês e o ano são os mesmos, e pede para retornar. Aí você usa outra condição com o dia:
function retornaMesAno
if month(varData) = month(now) AND year(varData) = year(now) then
return true
else
return false
end ifif day(varData)>=day(now)+3 AND retornaMesAno then
.
.
.
Isso não pode ser tão difícil assim... procure alguma coisa parecida aqui no fórum, e usa a lógica para adequar ao seu caso. qualquer coisa grita!
Nossa tá tando erro na primeira linha do código que você me passou, e não sei oque pode ser.
Tipo de erro:
Erro de compilação do Microsoft VBScript (0x800A03EA)
Erro de sintaxe
/sacintra/calendario/teste.asp, line 551
function retornaMesAno
A função não pode estar dentro de um laço, outra função ou condição if. E deve ser escrita antes de ser chamada.
Se já está assim, tenta chamá-la antes da condição
call retornaMesAno
if day(varData)>=day(now)+3 AND retornaMesAno then
.
.
.
você também pode tentar substituindo function por sub, tentaí
Ainda não estou conseguindo. Não sei nada de functiom.
Eu resolví postar a página inteira. Tá separado com **** a parte do código que estou mexendo
Agradeço por estar me ajudando. Nunca me deparei com algo assim antes.
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<% option explicit %>
<!--#include file="../Connections/SacIntra.asp" -->
<%
Session.Timeout = 60
Dim rs
Dim rs_cmd
Dim rs_numRows
Set rs_cmd = Server.CreateObject ("ADODB.Command")
rs_cmd.ActiveConnection = MM_SacIntra_STRING
rs_cmd.CommandText = "SELECT * FROM sacintra.rm WHERE dest_lab = 's' ORDER BY cod_rm DESC"
rs_cmd.Prepared = true
Set rs = rs_cmd.Execute
rs_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index
Repeat1__numRows = 50
Repeat1__index = 0
rs_numRows = rs_numRows + Repeat1__numRows
%>
<%
' *** Recordset Stats, Move To Record, and Go To Record: declare stats variables
Dim rs_total
Dim rs_first
Dim rs_last
' set the record count
rs_total = rs.RecordCount
' set the number of rows displayed on this page
If (rs_numRows < 0) Then
rs_numRows = rs_total
Elseif (rs_numRows = 0) Then
rs_numRows = 1
End If
' set the first and last displayed record
rs_first = 1
rs_last = rs_first + rs_numRows - 1
' if we have the correct record count, check the other stats
If (rs_total <> -1) Then
If (rs_first > rs_total) Then
rs_first = rs_total
End If
If (rs_last > rs_total) Then
rs_last = rs_total
End If
If (rs_numRows > rs_total) Then
rs_numRows = rs_total
End If
End If
%>
<%
Dim MM_paramName
%>
<%
' *** Move To Record and Go To Record: declare variables
Dim MM_rs
Dim MM_rsCount
Dim MM_size
Dim MM_uniqueCol
Dim MM_offset
Dim MM_atTotal
Dim MM_paramIsDefined
Dim MM_param
Dim MM_index
Set MM_rs = rs
MM_rsCount = rs_total
MM_size = rs_numRows
MM_uniqueCol = ""
MM_paramName = ""
MM_offset = 0
MM_atTotal = false
MM_paramIsDefined = false
If (MM_paramName <> "") Then
MM_paramIsDefined = (Request.QueryString(MM_paramName) <> "")
End If
%>
<%
' *** Move To Record: handle 'index' or 'offset' parameter
if (Not MM_paramIsDefined And MM_rsCount <> 0) then
' use index parameter if defined, otherwise use offset parameter
MM_param = Request.QueryString("index")
If (MM_param = "") Then
MM_param = Request.QueryString("offset")
End If
If (MM_param <> "") Then
MM_offset = Int(MM_param)
End If
' if we have a record count, check if we are past the end of the recordset
If (MM_rsCount <> -1) Then
If (MM_offset >= MM_rsCount Or MM_offset = -1) Then ' past end or move last
If ((MM_rsCount Mod MM_size) > 0) Then ' last page not a full repeat region
MM_offset = MM_rsCount - (MM_rsCount Mod MM_size)
Else
MM_offset = MM_rsCount - MM_size
End If
End If
End If
' move the cursor to the selected record
MM_index = 0
While ((Not MM_rs.EOF) And (MM_index < MM_offset Or MM_offset = -1))
MM_rs.MoveNext
MM_index = MM_index + 1
Wend
If (MM_rs.EOF) Then
MM_offset = MM_index ' set MM_offset to the last possible record
End If
End If
%>
<%
' *** Move To Record: if we dont know the record count, check the display range
If (MM_rsCount = -1) Then
' walk to the end of the display range for this page
MM_index = MM_offset
While (Not MM_rs.EOF And (MM_size < 0 Or MM_index < MM_offset + MM_size))
MM_rs.MoveNext
MM_index = MM_index + 1
Wend
' if we walked off the end of the recordset, set MM_rsCount and MM_size
If (MM_rs.EOF) Then
MM_rsCount = MM_index
If (MM_size < 0 Or MM_size > MM_rsCount) Then
MM_size = MM_rsCount
End If
End If
' if we walked off the end, set the offset based on page size
If (MM_rs.EOF And Not MM_paramIsDefined) Then
If (MM_offset > MM_rsCount - MM_size Or MM_offset = -1) Then
If ((MM_rsCount Mod MM_size) > 0) Then
MM_offset = MM_rsCount - (MM_rsCount Mod MM_size)
Else
MM_offset = MM_rsCount - MM_size
End If
End If
End If
' reset the cursor to the beginning
If (MM_rs.CursorType > 0) Then
MM_rs.MoveFirst
Else
MM_rs.Requery
End If
' move the cursor to the selected record
MM_index = 0
While (Not MM_rs.EOF And MM_index < MM_offset)
MM_rs.MoveNext
MM_index = MM_index + 1
Wend
End If
%>
<%
' *** Move To Record: update recordset stats
' set the first and last displayed record
rs_first = MM_offset + 1
rs_last = MM_offset + MM_size
If (MM_rsCount <> -1) Then
If (rs_first > MM_rsCount) Then
rs_first = MM_rsCount
End If
If (rs_last > MM_rsCount) Then
rs_last = MM_rsCount
End If
End If
' set the boolean used by hide region to check if we are on the last record
MM_atTotal = (MM_rsCount <> -1 And MM_offset + MM_size >= MM_rsCount)
%>
<%
' *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters
Dim MM_keepNone
Dim MM_keepURL
Dim MM_keepForm
Dim MM_keepBoth
Dim MM_removeList
Dim MM_item
Dim MM_nextItem
' create the list of parameters which should not be maintained
MM_removeList = "&index="
If (MM_paramName <> "") Then
MM_removeList = MM_removeList & "&" & MM_paramName & "="
End If
MM_keepURL=""
MM_keepForm=""
MM_keepBoth=""
MM_keepNone=""
' add the URL parameters to the MM_keepURL string
For Each MM_item In Request.QueryString
MM_nextItem = "&" & MM_item & "="
If (InStr(1,MM_removeList,MM_nextItem,1) = 0) Then
MM_keepURL = MM_keepURL & MM_nextItem & Server.URLencode(Request.QueryString(MM_item))
End If
Next
' add the Form variables to the MM_keepForm string
For Each MM_item In Request.Form
MM_nextItem = "&" & MM_item & "="
If (InStr(1,MM_removeList,MM_nextItem,1) = 0) Then
MM_keepForm = MM_keepForm & MM_nextItem & Server.URLencode(Request.Form(MM_item))
End If
Next
' create the Form + URL string and remove the intial '&' from each of the strings
MM_keepBoth = MM_keepURL & MM_keepForm
If (MM_keepBoth <> "") Then
MM_keepBoth = Right(MM_keepBoth, Len(MM_keepBoth) - 1)
End If
If (MM_keepURL <> "") Then
MM_keepURL = Right(MM_keepURL, Len(MM_keepURL) - 1)
End If
If (MM_keepForm <> "") Then
MM_keepForm = Right(MM_keepForm, Len(MM_keepForm) - 1)
End If
' a utility function used for adding additional parameters to these strings
Function MM_joinChar(firstItem)
If (firstItem <> "") Then
MM_joinChar = "&"
Else
MM_joinChar = ""
End If
End Function
%>
<%
' *** Move To Record: set the strings for the first, last, next, and previous links
Dim MM_keepMove
Dim MM_moveParam
Dim MM_moveFirst
Dim MM_moveLast
Dim MM_moveNext
Dim MM_movePrev
Dim MM_urlStr
Dim MM_paramList
Dim MM_paramIndex
Dim MM_nextParam
MM_keepMove = MM_keepBoth
MM_moveParam = "index"
' if the page has a repeated region, remove 'offset' from the maintained parameters
If (MM_size > 1) Then
MM_moveParam = "offset"
If (MM_keepMove <> "") Then
MM_paramList = Split(MM_keepMove, "&")
MM_keepMove = ""
For MM_paramIndex = 0 To UBound(MM_paramList)
MM_nextParam = Left(MM_paramList(MM_paramIndex), InStr(MM_paramList(MM_paramIndex),"=") - 1)
If (StrComp(MM_nextParam,MM_moveParam,1) <> 0) Then
MM_keepMove = MM_keepMove & "&" & MM_paramList(MM_paramIndex)
End If
Next
If (MM_keepMove <> "") Then
MM_keepMove = Right(MM_keepMove, Len(MM_keepMove) - 1)
End If
End If
End If
' set the strings for the move to links
If (MM_keepMove <> "") Then
MM_keepMove = Server.HTMLEncode(MM_keepMove) & "&"
End If
MM_urlStr = Request.ServerVariables("URL") & "?" & MM_keepMove & MM_moveParam & "="
MM_moveFirst = MM_urlStr & "0"
MM_moveLast = MM_urlStr & "-1"
MM_moveNext = MM_urlStr & CStr(MM_offset + MM_size)
If (MM_offset - MM_size < 0) Then
MM_movePrev = MM_urlStr & "0"
Else
MM_movePrev = MM_urlStr & CStr(MM_offset - MM_size)
End If
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="[http://www.w3.org/1999/xhtml">](http://www.w3.org/1999/xhtml)
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css"> margin-top: 0px;
}
.style4 {font-family: "Arial Black";
font-size: 20pt;
}.style32 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-weight: bold;
font-size: 9pt;
color: #FF0000;
}
.style33 {
font-family: Verdana, Arial, Helvetica, sans-serif;
color: #000000;
font-size: 7pt; }
.style34 {
font-family: Verdana, Arial, Helvetica, sans-serif;
color: #009900;
font-size: 7pt; }
.atrasado {
font-family: Verdana, Arial, Helvetica, sans-serif;
color: #cc0000;
font-size: 7pt; }
.aguardando {
font-family: Verdana, Arial, Helvetica, sans-serif;
color: #ff9900;
font-size: 7pt; }
.form { border: 1px solid #0066cc;
background-color: #ffffff;
font-family: verdana;
font-size: 12px;
color: #000000;
}
/ geral /
a.geral:link {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 8pt;
color: #000000;a.geral:hover {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 8pt;
color: #FFFFFF;
text-decoration: none;
background-color: #0066CC;
}
a.geral:active {
color: #000000;
text-decoration: none;a.geral:visited {
/ color: #000000; /
font-size: 8pt;
text-decoration: none;
} color: #000000;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 8pt;
}
-->
</style></head>
<body>
<table width="970" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="970" height="90" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="30" height="10"></td>
<td width="133" rowspan="5" valign="top"><img src="imagens/logo.jpg" width="133" height="89" /></td>
<td width="693"></td>
<td width="64"></td>
<td width="50"></td>
</tr>
<tr>
<td height="20"></td>
<td></td>
<td></td>
<td rowspan="2" valign="top" class="geral"><a href="logout_laboratorio.asp" class="geral"><strong>Sair</strong></a></td>
</tr>
<tr>
<td height="10"></td>
<td rowspan="2" valign="top"><div align="center"><span class="style4">Menu Laboratório</span></div></td>
<td></td>
</tr>
<tr>
<td height="31"></td>
<td></td>
<td> </td>
</tr>
<tr>
<td height="19"></td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table></td>
</tr>
<tr>
<td height="20"> </td>
</tr>
<tr>
<td height="201" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="970" height="190" valign="top"><form id="form1" name="form1" method="post" action="lab_busca_rm.asp">
<table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#000000">
<tr>
<td><table width="99%" border="0" align="center">
<tr>
<td width="5%"><span class="style33">Código:</span></td>
<td width="6%"><label>
<input name="txtbusca1" type="text" class="form" id="txtbusca1" size="5" maxlength="10" />
</label></td>
<td width="4%" class="style33">Nome:</td>
<td width="12%" class="style33"><label>
<input name="txtbusca2" type="text" class="form" id="txtbusca2" size="13" maxlength="100" />
</label></td>
<td width="7%" class="style33">Análise c\ Amostra:</td>
<td width="8%" class="style33"><select name="txtbusca3" id="txtbusca3">
<option value="%" selected="selected">-</option>
<option value="NÃO">NÃO</option>
<option value="SIM">SIM</option>
</select></td>
<td width="6%" class="style33"><label>Cheg. da Amostra:</label></td>
<td width="8%" class="style33"><label>
<select name="txtbusca4" id="txtbusca4">
<option value="%" selected="selected">-</option>
<option value="NÃO">NÃO</option>
<option value="SIM">SIM</option>
</select>
</label></td>
<td width="5%" class="style33">Info ao Sac:</td>
<td width="7%" class="style33"><select name="txtbusca5" id="txtbusca5">
<option value="%" selected="selected">-</option>
<option value="NÃO">NÃO</option>
<option value="SIM">SIM</option>
</select></td>
<td width="5%" class="style33">Situação:</td>
<td width="12%" class="style33"><select name="txtbusca6" id="txtbusca6">
<option value="%" selected="selected">-</option>
<option value="Aguardando">Aguardando</option>
<option value="Aprovado">Aprovado</option>
<option value="Recusado">Recusado</option>
</select></td>
<td width="15%" class="style33"><input type="submit" name="button" id="button" value="Buscar" />
<label>
<input type="button" value="Zerar" onclick="document.location='menu_laboratorio.asp'" name="button2" />
</label></td>
</tr>
</table></td>
</tr>
</table>
</form>
<table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#000000">
<tr>
<td><table width="100%" border="0">
<tr>
<td width="9%" bgcolor="#000000"><div align="center"><span class="style27">Código RM</span></div></td>
<td width="9%" bgcolor="#000000"><div align="center"><span class="style27">Público</span></div></td>
<td width="36%" bgcolor="#000000"><div align="center"><span class="style27">Nome/Empresa</span></div></td>
<td width="14%" bgcolor="#000000"><div align="center"><span class="style27">Data de Solicitação do Sac</span></div></td>
<td width="9%" bgcolor="#000000"><div align="center"><span class="style27">Análise com Amostra</span></div></td>
<td width="9%" bgcolor="#000000"><div align="center"><span class="style27">Chegada da Amostra</span></div></td>
<td width="7%" bgcolor="#000000"><div align="center"><span class="style27">Info ao SAC</span></div></td>
<td width="7%" bgcolor="#000000"><div align="center"><span class="style27">Situação</span></div></td>
</tr>
</table>
<% <table width="100%" border="0" bgcolor="#F3F3F3">
<tr>
<td width="9%"><div align="center" class="style32"><%= rs("cod_rm") %></div></td>
<td width="9%"><div align="center"><span class="style33"><%=(rs.Fields.Item("tipo").Value)%></span></div></td>
<% if rs("recolheu") = "SIM" then %>
<%
' ACAO - link
Dim varVerifica
varVerifica = rs("lab_situacao")
select case varVerifica
case "Aprovado"
varVerifica = "lab_detalhe_laudo.asp"
case "Recusado"
varVerifica = "lab_edita_laudo.asp"
case "Aguardando"
varVerifica = "lab_informa_sac.asp"
end select
%>
<td width="36%"><div align="left"> <a href="<%= varVerifica%>?cod=<%= rs("cod_rm")%>" class="geral"><%=(rs.Fields.Item("nome").Value)%></td>
<% else %>
<td width="36%"><div align="left"> <a href="lab_detalhe.asp?cod=<%= rs("cod_rm")%>" class="geral"><%=(rs.Fields.Item("nome").Value)%></td>
<% end if %>
*******************************************************************************
*******************************************************************************
*******************************************************************************
<%
Dim varColor, varData, mostra, diaVar
varData = rs("sac_data_lab")
'if day(now) >= day(varData)+3 then
function retornaMesAno
if month(varData) = month(now) AND year(varData) = year(now) then
return true
else
return false
end if
end function
call retornaMesAno
if day(varData)>=day(now)+3 AND retornaMesAno then
mostra = rs("sac_data_lab")
if rs("lab_situacao") = "Aprovado" then
varColor = "style34"
else
varColor = "atrasado"
end if
else
mostra = rs("sac_data_lab")
varColor = "style33"
end if
%>
*******************************************************************************
*******************************************************************************
*******************************************************************************
<td width="14%"><div align="center" class="<%= varColor %>"><%= mostra %></div></td>
<%
' COLETAR
Dim varColetar
varColetar = rs("coletar")
select case varColetar
case "SIM"
varColetar = "style34"
case "NÃO"
varColetar = "atrasado"
end select
%>
<td width="9%"><div align="center" class="<%= varColetar %>"><%=(rs.Fields.Item("coletar").Value)%></div></td>
<%
' RECOLHEU
Dim varRecolheu
varRecolheu = rs("recolheu")
select case varRecolheu
case "SIM"
varRecolheu = "style34"
case "NÃO"
varRecolheu = "atrasado"
end select
%>
<td width="9%"><div align="center"></span><span class="<%= varRecolheu %>"><%=(rs.Fields.Item("recolheu").Value)%></span></div></td>
<%
' INFO AO SAC
Dim varInfoSac
varInfoSac = rs("lab_avisa_sac")
select case varInfoSac
case "SIM"
varInfoSac = "style34"
case "NÃO"
varInfoSac = "atrasado"
end select
%>
<td width="7%"><div align="center"></span><span class="<%= varInfoSac %>"><%= rs("lab_avisa_sac")%></span></div></td>
<%
' SITUAÇÃO
Dim varSituacao
varSituacao = rs("lab_situacao")
select case varSituacao
case "Aprovado"
varSituacao = "style34"
case "Recusado"
varSituacao = "atrasado"
case "Aguardando"
varSituacao = "aguardando"
end select
%>
<td width="7%"><div align="center"><span class="<%= varSituacao %>"><%= rs("lab_situacao")%></span></div></td>
</tr>
</table>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
rs.MoveNext()
Wend
%></td>
</tr>
</table>
<table width="100%" border="0">
<tr>
<td height="45"><table border="0" align="center">
<tr>
<td><% If MM_offset <> 0 Then %>
<a href="<%=MM_moveFirst%>"><img src="First.gif" border=0></a>
<% End If ' end MM_offset <> 0 %> </td>
<td><% If MM_offset <> 0 Then %>
<a href="<%=MM_movePrev%>"><img src="Previous.gif" border=0></a>
<% End If ' end MM_offset <> 0 %> </td>
<td><% If Not MM_atTotal Then %>
<a href="<%=MM_moveNext%>"><img src="Next.gif" border=0></a>
<% End If ' end Not MM_atTotal %> </td>
<td><% If Not MM_atTotal Then %>
<a href="<%=MM_moveLast%>"><img src="Last.gif" border=0></a>
<% End If ' end Not MM_atTotal %> </td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td height="11"></td>
</tr>
</table></td>
</tr>
<tr>
<td height="20"> </td>
</tr>
</table>
</body>
</html>
<%
rs.Close()
Set rs = Nothing
%>Você determinou a função dentro de uma condição, isso dá erro mesmo. E a variável varData deve receber o valor do banco de dados antes de usá-la na condição. Mas ao invés de uma função, faça apenas assim:
<%
varData = rs("sac_data_lab") 'atribua o valor à variável antes de qualquer coisa
dim retornaMesAno 'agora é uma variável que recebe true ou false, esqueça a function
if month(varData) = month(now) AND year(varData) = year(now) then
retornaMesAno=true
else
retornaMesAno=false
end if
if day(varData)>=day(now)+3 AND retornaMesAno then
mostra = rs("sac_data_lab")
if rs("lab_situacao") = "Aprovado" then
varColor = "style34"
else
varColor = "atrasado"
end if
%>Eu testei assim aqui, com um banco de dados mySQL e deu certo... vamos ver se vai.
Não apresentou nenhum erro de página, más não funcionou o script
eu fiz até outra página com script que você me mandou para testar, e não funcioma mesmo.
Teste pra você ver.
Más agradeço mesmo pelo esforço que você está fazendo. Valeu!
varData = #22/10/2008#
dim retornaMesAno 'agora é uma variável que recebe true ou false, esqueça a function
if month(varData) = month(now) AND year(varData) = year(now) then
retornaMesAno=true
else
retornaMesAno=false
end if
if day(varData)>=day(now)+3 AND retornaMesAno then
Response.Write("No Prazo")
else
Response.Write("Atrazado")
end if
Descobri o que dava errado... segue o código corrigido
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1251"%>
<%
varData = #22/10/2008#
dim retornaMesAno 'agora é uma variável que recebe true ou false, esqueça a function
if month(varData) = month(now) AND year(varData) = year(now) then
retornaMesAno=true
else
retornaMesAno=false
end if
if day(varData)>=(day(now)+3) AND retornaMesAno then
Response.Write("No Prazo")
else
Response.Write("Atrasado")
end if
%>Nessa linha
if day(varData)>=(day(now)+3) AND retornaMesAno theno day(now)+3 tem que ficar entre parênteses, era só uma questão de lógica, heh!!
Testa uma página só com esse código, vai dar certo. testa com várias datas diferentes também
Não funcionou não. Rodei esse código do jeito que está e não funciona.
É só mudar o varData pra ver que não tá funcionando. Hoje é dia 24. Tipo se colocar dia 26 era pra exibir no Prazo.
varData = #26/10/2008#
Meu caso é muito difícil, e não tem nada igual na net.
Valeu mesmo por ajudar.
http://www.google.com.br/search?q=usando+datediff
veja se isso ajuda
Tenta isso aí:
<%
Dim varData
varData = cDate("20/10/2008")
If (DateDiff("d",varData,Date) <= 3) then
Response.Write("No Prazo")
Else
Response.Write("Atrasado")
End If
%>
Acho que o DateDiff resolve seu problema:
if DateDiff("d",Date,varData) >=3 then
response.write "Atrasado"
else
response.write "No prazo"
end ifFaça um teste, lembrando que a data no MySQL fica no format yyyy-mm-dd, pode ser que você precisa converter uma das duas datas