Ir para conteúdo
Fórum Script Brasil
  • 0

Como converter a data para o formato dd/mm/aa


Guest --Diego --

Pergunta

Guest --Diego --

Ola preciso de uma ajuda, tenho um site e mudaram o servidor, e depois da mudança meu banco de dados Access que tinha a data em dd/mm/aa agora esta mm/dd/aa, e não consigo reverter, será que alguém pode me ajudar???

segue o codigo abaixo:

<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="alpha.css" type="text/css">
</head>

<body bgcolor="#FFFFFF" text="#000000">
<%
Dim SCRIPT_NAME
SCRIPT_NAME = Request.ServerVariables("SCRIPT_NAME")
dim DB
DB = "carteira"


' I use this link a lot so I threw it into a "pseudo-const"
' so I don't have to keep typing it.
Dim BACK_TO_LIST_TEXT
BACK_TO_LIST_TEXT = "<p>Clique <a href=""" & SCRIPT_NAME & """>" _
    & "aqui</a> para voltar para a lista.</p>"


' Declare our standard variables.
Dim cnnDBEdit, rstDBEdit  ' ADO objects

Dim strSQL      ' To hold various SQL Strings
Dim iRecordId   ' Used to keep track of the record in play

' Choose what to do by looking at the action parameter
opcao = Request.QueryString("action")
Select Case LCase(Trim(opcao))
    Case "add"
                %>

<form action="<%= SCRIPT_NAME %>?action=process" method="post">
  <table width="500" border="0" cellspacing="0" cellpadding="0">
    <tr> 
      <td class="tit_col">Cadastrando novo Campo</td>
    </tr>
    <tr> 
      <td class="borda"> 
        <table width="100%" border="0" cellspacing="0" cellpadding="0" >
          <tr> 
            <td> 
              <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr> 
                  <td width="51%" class="form1">Data:</td>
                  <td width="49%" class="form2"> 
                    <input class="formfield" type="text" name="data" size="12" maxlength="10"  />
                    dd/mm/aaaa</td>
                </tr>
                <tr> 
                  <td width="51%" class="form1">Valor da cota:</td>
                  <td width="49%" class="form2"> 
                    <input class="formfield" type="text" name="cota" size="10" maxlength="10"  />
                  </td>
                </tr>
                <tr> 
                  <td width="51%" class="form1">Rendimento no dia </td>
                  <td width="49%" class="form2"> 
                    <input class="formfield" type="text" name="rend_dia" size="10" maxlength="10"  />
                  </td>
                </tr>
                <tr> 
                  <td width="51%" class="form1">Rendimento no mês</td>
                  <td width="49%" class="form2"> 
                    <input class="formfield" type="text" name="rend_mes" size="10" maxlength="10"  />
                  </td>
                </tr>
                <tr> 
                  <td width="51%" class="form1">Rendimento no ano</td>
                  <td width="49%" class="form2"> 
                    <input class="formfield" type="text" name="rend_ano" size="10" maxlength="10"  />
                  </td>
                </tr>
                <tr> 
                  <td colspan="2" bgcolor="#CCCCCC"> 
                    <div align="center"> 
                      <input type="submit" name="confirma" value="Confirma" class="formbutton">
                    </div>
                  </td>
                </tr>
              </table>
            </td>
          </tr>
        </table>
      </td>
    </tr>
  </table>
  
</form>
                 <%
    Case "process"

            strSQL = "INSERT INTO " & DB _
            & " (data, cota, rend_dia, rend_mes, rend_ano) " _
            & "VALUES ('" & request.form("data") _
            & "', '" & request.form("cota") _
            & "', '" & request.form("rend_dia") _
            & "', '" & request.form("rend_mes") _
            & "', '" & request.form("rend_ano") & "')"
                Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "DBQ=" & Server.MapPath("..\httpdocs\dados\informacoes.mdb") & ";" & _
    "DRIVER={Microsoft Access Driver (*.mdb)};"

               set rstDBEdit = conn.execute(strSQL)

                Set rstDBEdit = Nothing
                 Response.Write(BACK_TO_LIST_TEXT)
    Case "delete"
        ' Get the id to delete
        iRecordId = Request.QueryString("id")
        If IsNumeric(iRecordId) Then
            iRecordId = CLng(iRecordId)
        Else
            iRecordId = 0
        End If

        strSQL = "DELETE FROM " & db & " WHERE id=" & iRecordId & ";"
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "DBQ=" & Server.MapPath("..\httpdocs\dados\informacoes.mdb") & ";" & _
    "DRIVER={Microsoft Access Driver (*.mdb)};"

                set rstDBEdit = conn.execute(strSQL)


                conn.Close
        Set cnnDBEdit = Nothing

        Response.Write("Record Id #" & iRecordId & " deleted!")
        Response.Write(BACK_TO_LIST_TEXT)
    Case "edit"
        ' First of a 2 part process... build a form with the
        ' values from the db.
        iRecordId = Request.QueryString("id")
        If IsNumeric(iRecordId) Then
            iRecordId = CLng(iRecordId)
        Else
            iRecordId = 0
        End If
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "DBQ=" & Server.MapPath("..\httpdocs\dados\informacoes.mdb") & ";" & _
    "DRIVER={Microsoft Access Driver (*.mdb)};"
        strSQL = "SELECT * FROM " & DB & " WHERE id=" & iRecordId & ";"
                set rstDBEdit = conn.execute(strSQL)


        If Not rstDBEdit.EOF Then
            %>
            
<p>  </p>

            <form action="<%= SCRIPT_NAME %>?action=editsave&id=<%= rstDBEdit.Fields(0).Value %>" method="post">
  <table width="500" border="0" cellspacing="0" cellpadding="0">
    <tr> 
      <td class="tit_col">Editando Campo</td>
    </tr>
    <tr> 
      <td class="borda"> 
        <table width="100%" border="0" cellspacing="0" cellpadding="0" >
          <tr> 
            <td> 
              <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr> 
                  <td width="50%" class="form1">Data:</td>
                  <td width="50%" class="form2"> 
                    <input class="formfield" type="text" name="data" size="12" maxlength="10" value="<%= rstDBEdit.Fields(1).Value %>"  />
                    dd/mm/aaaa</td>
                </tr>
                <tr> 
                  <td width="50%" class="form1">Valor da cota:</td>
                  <td width="50%" class="form2"> 
                    <input class="formfield" type="text" name="cota" size="10" maxlength="10" value="<%= rstDBEdit.Fields(2).Value %>"  />
                  </td>
                </tr>
                <tr> 
                  <td width="50%" class="form1">Rendimento no dia </td>
                  <td width="50%" class="form2"> 
                    <input class="formfield" type="text" name="rend_dia" size="10" maxlength="10" value="<%= rstDBEdit.Fields(3).Value %>"  />
                  </td>
                </tr>
                <tr> 
                  <td width="50%" class="form1">Rendimento no mês</td>
                  <td width="50%" class="form2"> 
                    <input class="formfield" type="text" name="rend_mes" size="10" maxlength="10" value="<%= rstDBEdit.Fields(4).Value %>"  />
                  </td>
                </tr>
                <tr> 
                  <td width="50%" class="form1">Rendimento no ano</td>
                  <td width="50%" class="form2"> 
                    <input class="formfield" type="text" name="rend_ano" size="10" maxlength="10" value="<%= rstDBEdit.Fields(5).Value %>"  />
                  </td>
                </tr>
                <tr> 
                  <td colspan="2" bgcolor="#CCCCCC"> 
                    <div align="center"> 
                      <input type="submit" name="confirma2" value="Confirma" class="formbutton">
                    </div>
                  </td>
                </tr>
              </table>
            </td>
          </tr>
        </table>
      </td>
    </tr>
  </table>
  </form>
            
<%
        Else
            Response.Write "Record not found!"
        End If

        rstDBEdit.Close
        Set rstDBEdit = Nothing

        Response.Write(BACK_TO_LIST_TEXT)

    Case "editsave"
        ' Part 2 of 2: Here's where we save the values that the
        ' user entered back to the DB.  Again... no error
        ' handling or input checking so ' characters and invalid
        ' values will throw error messages.
        iRecordId = Request.querystring("id")
        iRecordId = Replace(iRecordId, "'", "''")

        ' Date delimiter on this should be changed to # for Access
        strSQL = "UPDATE " & DB & " SET " _
            & "data = '" & Request.Form("data") & "', " _
            & "cota = '" & Request.Form("cota") & "', " _
            & "rend_dia = '" & Request.Form("rend_dia") & "', " _
            & "rend_mes = '" & Request.Form("rend_mes") & "', " _
            & "rend_ano = '" & Request.Form("rend_ano") & "' " _
            & "WHERE (id = " & iRecordId & ")"


Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "DBQ=" & Server.MapPath("..\httpdocs\dados\informacoes.mdb") & ";" & _
    "DRIVER={Microsoft Access Driver (*.mdb)};"

                set rstDBEdit = conn.execute(strSQL)


        conn.Close
        Set conn = Nothing

        Response.Write("<p>Record Id #" & iRecordId & " updated!</p>")
        Response.Write(BACK_TO_LIST_TEXT)
    Case Else ' view
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "DBQ=" & Server.MapPath("..\httpdocs\dados\informacoes.mdb") & ";" & _
    "DRIVER={Microsoft Access Driver (*.mdb)};"
        strSQL = "SELECT * FROM " & DB & " ORDER BY id DESC;"

                set rstDBEdit = conn.execute(strSQL)

                %>
<a href="adm_menu.asp">Menu Principal</a>
<table border="0" cellspacing="0" cellpadding="0" width="750">
  <tr> 
    <td colspan="8" class="texc_tab" align="right"><a href="<%= SCRIPT_NAME %>?action=add">Adiciona</a></td>
  </tr>

  <tr> 
    <th class="tit_tab">Id</th>
    <th class="tit_tab">Data</th>
    <th class="tit_tab">Indice</th>
    <th class="tit_tab">Rendimento no dia</th>
    <th class="tit_tab">Rrendimento no Mês</th>
    <th class="tit_tab">Rendimento no Ano</th>
    <th class="tit_tab">Deleta</th>
    <th class="tit_tab">Edita</th>
  </tr>

  <%
        Do While Not rstDBEdit.EOF
        if tipolinha = "texc_tab" then
        tipolinha = "texd_tab"
        else
        tipolinha = "texc_tab"
        end if
            %>
  <tr> 
    <td class="<%response.write tipolinha%>" height="20"><%= rstDBEdit.Fields("id").Value %></td>
    <td class="<%response.write tipolinha%>" height="20"><%= Server.HTMLEncode(rstDBEdit.Fields("data").Value) %></td>
    <td class="<%response.write tipolinha%>" height="20"><%= rstDBEdit.Fields("cota").Value %></td>
    <td class="<%response.write tipolinha%>" height="20"><%= rstDBEdit.Fields("rend_dia").Value %></td>
    <td class="<%response.write tipolinha%>" height="20"><%= rstDBEdit.Fields("rend_mes").Value %></td>
    <td class="<%response.write tipolinha%>" height="20"><%= rstDBEdit.Fields("rend_ano").Value %></td>
    <td class="<%response.write tipolinha%>" height="20"><a href="<%= SCRIPT_NAME %>?action=delete&id=<%= rstDBEdit.Fields("id").Value %>">Deleta</a></td>
    <td class="<%response.write tipolinha%>" height="20"><a href="<%= SCRIPT_NAME %>?action=edit&id=<%= rstDBEdit.Fields("id").Value %>">Edita</a></td>
  </tr>
  <%
            rstDBEdit.MoveNext
        Loop
        %>

</table>
<a href="adm_menu.asp">Menu Principal</a> 
<%
        rstDBEdit.Close
        Set rstDBEdit = Nothing
End Select
%>
</body>
</html>

Editado por kuroi
Adicionar tag CODE
Link para o comentário
Compartilhar em outros sites

3 respostass a esta questão

Posts Recomendados

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,3k
    • Posts
      652,2k
×
×
  • Criar Novo...