Jump to content


Photo

Busca Entre 2 Datas


  • Faça o login para participar
1 reply to this topic

#1 Ronaldo B. Nunes

Ronaldo B. Nunes

    Novato no fórum

  • Usuários
  • 1 posts
  • Sexo:Masculino
  • Localidade:Embu das Artes São Paulo

Posted 02/03/2010, 22:31

Caros colegas, estou quebrando a cabeça para Desenvolver um sistema de busca entre 2 datas. segue meu script Gostaria que alguem me ajudasse colocar um outro campo onde pudessemos colocar uma data inicial ea data final para o sistema iniciar uma busca.

DOCTYPE HTML PUBLIC "- / / W3C / / DTD HTML 4.01 Transitional / / EN">
<!--# Include file = _cnx.asp "->

<%
iper = Int (Trim (Request ( "mu")))
Acesso (IPER)
iMod = "Clientes"
iMod2 = "Clintesfv"
irck = "Cardápios"
iempresa = "RCK BUFFET FOTO E VIDEO"
%>
<html>

<!--# Include file = topo2.asp "->
<!--# Include file = cabecalho.asp "->




<head>
<link icon" href="/favicon.ico">
<title> cjasse </ title>
LANGUAGE="JavaScript1.2" <script src="suport/common.js"> </ script>
LANGUAGE="JavaScript1.2" <script src="suport/leftframe.js"> </ script>

<link rel="stylesheet" type="text/css" href="suport/general.css">
<link rel="stylesheet" type="text/css" href="suport/custommain.css">
<link rel="stylesheet" type="text/css" href="suport/layoutMain.css">
<link rel="stylesheet" type="text/css" href="suport/desktopmain.css">
<link rel="stylesheet" type="text/nonsense" href="suport/misc.css">


<script type="text/javascript">
<! --
Função _body_onload ()
(
setScrollInIE ();
turnAutocompleteOff ();
loff ();
var std_context = 'cl_home';
SetHelpPrefix (CL'/'); std_context SetContext (,'');
setActiveButtonByName ( "Domínios");

try (
if (top top.leftFrame & &) (
SetExpandLeftFrame ();
)
) Catch (e) ()
)

Função _body_resize ()
(
setScrollInIE ();
lresize ();
)

Função _body_onunload ()
(
lon ();

)


opt_no_frames var = false;
var opt_integrated_mode = false;
função _key_hadler_onkeypress (e)
(
var event = e? e: window.event;
var target = e? event.target: event.srcElement;
var key = event.keyCode;

if (navigator.appName == "Netscape" & &
(navigator.platform.indexOf ( "Mac") == -1 & & tecla == 112 | |
navigator.platform.indexOf ( "Mac")> -1 & & key == 63236)
) (OpenHelpWindow (); return false;);

try (
if (target.name == "filtro") (if (tecla == "13") (DomainsListFilter (document.forms [0]); return false;)) if (tecla == "13") (
if (target & & (target.type == "button" | | target.type == "textarea"))
return true;
bt = document.getElementById ( "oferta" ok ");
if (navigator.appName == "Netscape")
(
if (BT bt.onclick) ();
)
Diferente
(
if (BT bt.click) ();
)
return false;) if (tecla == "27") (
bt = document.getElementById ( "oferta" Cancelar ");
if (navigator.appName == "Netscape")
(
if (BT bt.onclick) ();
)
Diferente
(
if (BT bt.click) ();
)
return false;)
) Catch (e) (
)
return true;
)
if (document.layers) document.captureEvents (Event.KEYPRESS);
document.onkeypress = _key_hadler_onkeypress;



//-->
</ Script>
<style type="text/css">
<! --
. style1 (color: # FF0000)
->
</ Style>

</ Head>
<div class="screenSubTitle"> </ div>
<div id="screenTabs">
<div id="tabs">
<div class="screenBody" id="screenClient">
</ Div> </ div>
<input type="text" name="iesingletextinputworkaround" deficientes style="display: none">

<body onLoad="_body_onload();" onUnload="_body_onunload();" onResize="_body_resize();" retorno onHelp="OpenHelpWindow(); false;" id="mainCP" class="MainFrameBody">

<a href="#" name="top" id="top"> </ a>
<td <table border="0" cellspacing="0" cellpadding="0" id="loaderContainer" onClick="return false;"> id="loaderContainerWH"> </ div style id = "loader" = "z -index: 10; "> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <td> <p> alt </ img loading.gif =" "title =" "width =" 32 "height =" 32 "src =" imagens "/ loading.gif"> <strong> Por favor. <br> Aguarde ...</ strong> </ p> </ td> </ tr > </ table> </ div> <script> _lon ();</ script> </ td> </ tr> </ table>
<table width="100%" cellspacing="0" cellpadding="0" border="0" id="pageLayout"> <td id="screenWH">
<!--< Div class = "Barra de trajeto"> <a href="#" openScreen('dashboard1', onClick="return'general.asp');"> Área de Trabalho </ a> ->

<span class="style1">
<p> <font face="Tahoma" size="2">
</ Font> </ p> </ span>



<fieldset>

Buscar <legend> <% iMod =%> </ legend> <table width="100%" cellspacing="0" cellpadding="0" border="0"> <td>
<br>
<br>
<br>
<br>
<br>

<table width="100%" cellspacing="0" cellpadding="0" border="0"> <td>
<table width="100%" cellspacing="0">
<tr>
<td>
<form action ="<%= LCase (iMod)%> _all.asp "method =" post "name = frmBusca" frmBusca id = "">
<div align="center">
<select name="q" style="width: 250px;">
<option value="[A11DEQUEM]" selected> DE QUEM </ option>
<option value="[A01NOME]"> Nome </ option>
<option value="[A08CPF]"> CPF </ option>
<option value="[A00ID]"> NÚMERO DO CONTRATO </ option>
<option value="[A50DT_CASAMENTO]"> DADOS DO EVENTO </ option>
</ Select>
                            
<select name="t" class="ud_caixa">
<option value=" Like "selected> que contenha </ option>
<option value=" = "> igual a. .. </ Option>
<option value="entre"> entre </ option>
</ Select>
                            
<input type="text" name="totext" value="" size="20" maxlength="245">
<input type = nome = valor "submit" "Procurar" = estilo "Procurar" (imagens = "background: / url btn_search_bg.gif) no-repeat left; border: nenhum white; height: 20px; CURSOR: hand; ">
</ Div>
</ Form>
</ Td>
</ Tr>
</ Table>
</ Div>
<br>
<br>
<br>
<br>
<br>

<div class="paging">

</ Div>

<%
'On Error Resume Next
Dim Connect_String
Dim PAGE_SIZE
Dim StartPage
Current_page Dim
Page_count Dim
Dim CssClass
Dim CellValue
IntRowCount Dim
Dim SQL
Dim i, strTemp, corTR, cordata

scampo = Request ( "Q")
sTipo = Request ( "t")
sValor = Request (totext ")

Se sValor Trim () = "" Then
'SQL = "SELECT * FROM" & LCase (iMod) & "Order By [A00ID] Desc"

data1 = Ano (dados )&"-"& mês (dados )&"-"& Day (data)
data2 = DateAdd ( "d", 365, dados)
data3 = Year (Data2 )&"-"& Month (data2 )&"-"& Day (data2)
SQL = "SELECT * FROM" & LCase (iMod) & "WHERE A50DT_CASAMENTO Between #" & data1 & "# And #" & data3 & "# por ordem A50DT_CASAMENTO"

ElseIf Trim (Stipo) = "entre" Então
data1 = Left (sValor, 10)
data2 = sValor Right (, 10)
SQL = "SELECT * FROM" & LCase (iMod) & "WHERE A50DT_CASAMENTO Between #" & data1 & "# And #" & data2 & "# por ordem A50DT_CASAMENTO"

Diferente
Se STIPO Trim () = "Like" Então
SQL = "SELECT * FROM" & LCase (iMod) & "Where" & scampo & "" & sTipo &% " '" & sValor & "%'"
Diferente
SQL = "SELECT * FROM" & LCase (iMod) & "Where" & scampo & "" & sTipo & " '" & sValor & "'"
End If
End If

RsTemp Set = Server.CreateObject ( "ADODB.Recordset")
rsTemp.CursorLocation = 3
If Request ( "Page") = "" Then
Current_page = 1
Diferente
Current_page = CInt (Request ( "Page"))
End If

PAGE_SIZE = "60"
rsTemp.PageSize = PAGE_SIZE
SQL rsTemp.Open, objConect

Page_count = rsTemp.PageCount
Se current_page <1 Then current_page = 1
Se current_page> current_page Então page_count = page_count
Se page_count> = 0 então rsTemp.AbsolutePage current_page
%>

</ Td>
</ Tr> </ table>


</ P>

</ Td>
</ Tr>
</ Table>


</ Table>


<script type="text/javascript"> função SwitchLeftFrame () (if (typeof (top.GetBarExpanded)! = "undefined") (ExpandLeftFrame (! Função ());}} ExpandLeftFrame top.GetBarExpanded (f) (var i = document.getElementById (imgLeftFrameSwitcher "), se (i) (i.src =" imagens / Bar_ "+ (f?" fechar ":" abrir ")+". gif "; top.FoldFrame (f)<img src='http://forum.wmonline.com.br/public/style_emoticons/default/wink.gif' class='bbc_emoticon' alt=';)' />) SetExpandLeftFrame função () (if (typeof (top.GetBarExpanded)! = "undefined") (ExpandLeftFrame (top.GetBarExpanded ());}}</ script>
<div class="LeftFrameSwitcher" id="divLeftFrameSwitcher"> <img src = "imagens" / bar_close.gif "alt = bar_close.gif" name = imgLeftFrameSwitcher "imgLeftFrameSwitcher id =" "border =" 0 "title =" Esconder / Mostrar navegação "onClick =" SwitchLeftFrame ();"></ div>

</ Body>
</ Html>


#2 Fernando C

Fernando C

    Ativo

  • Usuários
  • 371 posts
  • Sexo:Masculino
  • Localidade:SP

Posted 05/03/2010, 11:02

Olá, Ronaldo bem vindo ao forum..

Rapaz, n vi teu codigo todo, mas a logica de uma busca assim é bastante simples, resumidamente: crie num formulario dois campos p/ vc digitar as datas (aconselho não usar espaços) - vamos chama-los de campo_do_formulario_1 e campo_do_formulario_2 só p/ vc entender melhor - e 1 botão submit p/ disparar o procedimento - isso é HTML puro e simples, mas em ASP é aconselhavel vc salvar o arquivo com a extensão ASP mesmo.

Já a pagina q vai receber os conteudos dos campos (pode ser a mesma) e exibir o resultado seguindo os parametros q vc passou (parametros = conteudos dos campos) é 1 pouco + complexa;
resumidamente ela teria q ter 1 comando select no banco de dados semelhante a isso:

Select campos
from tabela 
where dia between campo_do_formulario_1 e  campo_do_formulario_2;

verifique teu codigo, está assim:
Between #" & data1 & "# And #" & data3 & "# por ordem A50DT_CASAMENTO"

(alias esse por ordem acho q n tem nada a ver, ordenação em banco de dados se faz pela frase ORDER BY)

Essa é a consulta ao banco, mas ainda em ASP vc deverá configurar outros elementos, como conexão, filtro (declarar q esses parametros da busca serão fornecidos por um formulário - pesquise sobre QueryString) entre outros..

pesquisei algumas dicas no Google; veja:

http://www.google.co...:pt-BR:official

e qqer coisa retorne




1 user(s) are reading this topic

0 membro(s), 1 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq