Autor Tema: Mis fechas salen 01/01/1900 ... [ SOLUCIONADO ]  (Leído 5986 veces)

0 Usuarios y 1 Visitante están viendo este tema.

omarinho23

  • Megabyte
  • ***
  • Mensajes: 105
  • Reputación: +0/-1
    • Ver Perfil
Mis fechas salen 01/01/1900 ... [ SOLUCIONADO ]
« en: Enero 26, 2010, 06:43:33 pm »
hola que tal de nuevo! haber!! :P bueno todo esta bien... lo unico raro es q la fecha cuando graba se graba con este dia 01/01/1900 ... y no entiendo porque :S

este es mi codigo para guardar

Código: [Seleccionar]
cnn.Execute "INSERT INTO Clientes (voucher, dia, contacto, razonsocial, nºderuc, direccion, inspector, tipodecertificado, cantidad, precio, total, codigodebarra, cit, nºdeplaca, nºdemotor, nºdeserieochasis, nºdecertificado, totalvoucher, boletaofactura, mes, lista, asignacion, observacion) VALUES('" & Text1(1) & "',Convert(DateTime, " & Date & ", 103),'" & Text1(3) & "','" & Text1(4) & "','" & Text1(5) & "','" & Text1(6) & "','" & Text1(7) & "','" & Text1(8) & "','" & Text1(9) & "','" & Text1(10) & "','" & Text1(11) & "','" & Text1(12) & "','" & Text1(13) & "','" & Text1(14) & "','" & Text1(15) & "','" & Text1(16) & "','" & Text1(17) & "','" & Text1(18) & "','" & Text1(19) & "','" & Text1(20) & "','" & Text1(21) & "','" & Text1(22) & "','" & Text1(23) & "')"
« última modificación: Enero 27, 2010, 11:22:19 am por omarinho23 »

ssccaann43

  • Moderador
  • Terabyte
  • *****
  • Mensajes: 970
  • Reputación: +97/-58
    • Ver Perfil
    • Sistemas Nuñez, Consultores y Soporte, C.A.
Re:Mis fechas salen 01/01/1900 ... ; /
« Respuesta #1 en: Enero 26, 2010, 06:57:30 pm »
 A ver...

En el Form_Load de tu formulario declara esta variable

Dim FechaActual as Date

Seguido de esto, luego de declararlo, asignale la fecha actual.

FechaActual = Date

Y por último, sustituye el Date de tu Query por FechaActual.
Miguel Núñez.

omarinho23

  • Megabyte
  • ***
  • Mensajes: 105
  • Reputación: +0/-1
    • Ver Perfil
Re:Mis fechas salen 01/01/1900 ... ; /
« Respuesta #2 en: Enero 26, 2010, 07:05:45 pm »
no capto.... ???

haber en mi form_load ya agrega dim fechaactual as date
donde pongo

FechaActual = Date

i el resto

ssccaann43

  • Moderador
  • Terabyte
  • *****
  • Mensajes: 970
  • Reputación: +97/-58
    • Ver Perfil
    • Sistemas Nuñez, Consultores y Soporte, C.A.
Re:Mis fechas salen 01/01/1900 ... ; /
« Respuesta #3 en: Enero 26, 2010, 07:13:25 pm »
donde pongo

FechaActual = Date
A ver...

En el Form_Load de tu formulario declara esta variable

Dim FechaActual as Date

Seguido de esto, luego de declararlo, asignale la fecha actual.

FechaActual = Date

Y por último, sustituye el Date de tu Query por FechaActual.

Private Sub Form_Load()
Dim FechaActual as Date

FechaActual = Date
End Sub
Y en el query sustituyes Date por FechaActual y te queda así.
Código: [Seleccionar]
cnn.Execute "INSERT INTO Clientes (voucher, dia, contacto, razonsocial, nºderuc, direccion, inspector, tipodecertificado, cantidad, precio, total, codigodebarra, cit, nºdeplaca, nºdemotor, nºdeserieochasis, nºdecertificado, totalvoucher, boletaofactura, mes, lista, asignacion, observacion) VALUES('" & Text1(1) & "',Convert(DateTime, " & FechaActual & ", 103),'" & Text1(3) & "','" & Text1(4) & "','" & Text1(5) & "','" & Text1(6) & "','" & Text1(7) & "','" & Text1(8) & "','" & Text1(9) & "','" & Text1(10) & "','" & Text1(11) & "','" & Text1(12) & "','" & Text1(13) & "','" & Text1(14) & "','" & Text1(15) & "','" & Text1(16) & "','" & Text1(17) & "','" & Text1(18) & "','" & Text1(19) & "','" & Text1(20) & "','" & Text1(21) & "','" & Text1(22) & "','" & Text1(23) & "')"
Miguel Núñez.

omarinho23

  • Megabyte
  • ***
  • Mensajes: 105
  • Reputación: +0/-1
    • Ver Perfil
Re:Mis fechas salen 01/01/1900 ... ; /
« Respuesta #4 en: Enero 26, 2010, 07:22:24 pm »
bueno puse todo pero me señala el error

Incorrect Sysntax near ':'.

y me señala

Código: [Seleccionar]
cnn.Execute "INSERT INTO Clientes (voucher, dia, contacto, razonsocial, nºderuc, direccion, inspector, tipodecertificado, cantidad, precio, total, codigodebarra, cit, nºdeplaca, nºdemotor, nºdeserieochasis, nºdecertificado, totalvoucher, boletaofactura, mes, lista, asignacion, observacion) VALUES('" & Text1(1) & "',Convert(DateTime, " & FechaActual & ", 103),'" & Text1(3) & "','" & Text1(4) & "','" & Text1(5) & "','" & Text1(6) & "','" & Text1(7) & "','" & Text1(8) & "','" & Text1(9) & "','" & Text1(10) & "','" & Text1(11) & "','" & Text1(12) & "','" & Text1(13) & "','" & Text1(14) & "','" & Text1(15) & "','" & Text1(16) & "','" & Text1(17) & "','" & Text1(18) & "','" & Text1(19) & "','" & Text1(20) & "','" & Text1(21) & "','" & Text1(22) & "','" & Text1(23) & "')"

entonces esta bien asi como lo puse

Citar
Option Explicit

Enum EACCION
    AGREGAR_REGISTRO = 0
    EDITAR_REGISTRO = 1
End Enum

Public IdRegistro
Public ACCION As EACCION



Private Sub cmdGuardar_Click()
Dim FechaActual As Date
Text1(11).Text = ((Val(Text1(9).Text) * Val(Text1(10).Text)))
Text1(22).Text = ((Val(Text1(11).Text * 0.3) / 1.19))


    'Agrega el registro
    '''''''''''''''''''''''''''''''
   
    Select Case ACCION
    Case EDITAR_REGISTRO
        cnn.Execute "UPDATE Clientes set voucher = '" & Text1(1) & _
                                         "', dia = '" & Text1(2) & _
                                         "', contacto = '" & Text1(3) & _
                                         "', razonsocial = '" & Text1(4) & _
                                         "', nºderuc = '" & Text1(5) & _
                                         "', direccion = '" & Text1(6) & _
                                         "', inspector = '" & Text1(7) & _
                                         "', tipodecertificado = '" & Text1(8) & _
                                         "', cantidad = '" & Text1(9) & _
                                         "', precio = '" & Text1(10) & _
                                         "', total= '" & Text1(11) & _
                                         "', codigodebarra = '" & Text1(12) & _
                                         "', cit = '" & Text1(13) & _
                                         "', nºdeplaca = '" & Text1(14) & _
                                         "', nºdemotor = '" & Text1(15) & _
                                         "', nºdeserieochasis = '" & Text1(16) & _
                                         "', nºdecertificado = '" & Text1(17) & _
                                         "', totalvoucher = '" & Text1(18) & _
                                         "', boletaofactura = '" & Text1(19) & _
                                         "', mes = '" & Text1(20) & _
                                         "', lista = '" & Text1(21) & _
                                         "', asignacion = '" & Text1(22) & _
                                         "', observacion = '" & Text1(23) & _
                                         "' where Cod = " & IdRegistro & ""
    Case AGREGAR_REGISTRO
       
cnn.Execute "INSERT INTO Clientes (voucher, dia, contacto, razonsocial, nºderuc, direccion, inspector, tipodecertificado, cantidad, precio, total, codigodebarra, cit, nºdeplaca, nºdemotor, nºdeserieochasis, nºdecertificado, totalvoucher, boletaofactura, mes, lista, asignacion, observacion) VALUES('" & Text1(1) & "',Convert(DateTime, " & FechaActual & ", 103),'" & Text1(3) & "','" & Text1(4) & "','" & Text1(5) & "','" & Text1(6) & "','" & Text1(7) & "','" & Text1(8) & "','" & Text1(9) & "','" & Text1(10) & "','" & Text1(11) & "','" & Text1(12) & "','" & Text1(13) & "','" & Text1(14) & "','" & Text1(15) & "','" & Text1(16) & "','" & Text1(17) & "','" & Text1(18) & "','" & Text1(19) & "','" & Text1(20) & "','" & Text1(21) & "','" & Text1(22) & "','" & Text1(23) & "')"
                                 
    End Select
   
    rs.Requery 1
   
    Call CargarListView(FrmPrincipalCarmen.LV, rs)


    FechaActual = Date
    DoEvents
    Unload Me
    Set FrmEditCarmen = Nothing
Exit Sub
ErrorSub:
MsgBox Err.Description

End Sub

Private Sub cmdCancelar_Click()
    Unload Me
End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyEscape Then
       Unload Me
    End If
End Sub



Private Sub Text1_Change(Index As Integer)
Text1(22) = Format(Text1(22), "#0.00")
Text1(11) = Format(Text1(11), "#0.00")
Text1(18) = Format(Text1(18), "#0.00")
End Sub

« última modificación: Enero 26, 2010, 07:42:04 pm por omarinho23 »

YAcosta

  • Moderador Global
  • Exabyte
  • *****
  • Mensajes: 2853
  • Reputación: +160/-38
  • Daddy de Qüentas y QüeryFull
    • Ver Perfil
    • Personal
Re:Mis fechas salen 01/01/1900 ... ; /
« Respuesta #5 en: Enero 27, 2010, 02:33:14 am »
Mira, yo ya no me complico la vida porque ese tema siempre me ha sido muy molesto, yo ahora hago esto:

Dim sqlDate as String

sqlDate = Format (Date, "YYYY/MM/DD")

y en tu código de inserción o actualización (ajustando la cadena claro):
...Text1(1) & ", '" & sqlDate & "', " & Text1(3) & ...

Y si lo que quieres es guardar con el formato largo entonces:
sqlDate = Format (Date, "YYYY/MM/DD HH:MM:SS")

y nunca mas tuve problemas.
Me encuentras en YAcosta.com

omarinho23

  • Megabyte
  • ***
  • Mensajes: 105
  • Reputación: +0/-1
    • Ver Perfil
Re:Mis fechas salen 01/01/1900 ... ; /
« Respuesta #6 en: Enero 27, 2010, 11:22:00 am »
wow YvanB! ... muchas gracias! me salvaste! ... gracias ssccaann por tu tiempo tomado tmb! muchas gracias muchachos!