Seleccionar un rango de fechas de una tabla
Publicado por Adolfo (55 intervenciones) el 27/06/2016 02:45:07
Tengo el siguiente codigo de programacion que lee los datos de una tabla (TBCierreDiario) de acuardo al
rango de fechas indicado en el SELECT, los datos en la tabla estan en formato fecha dd/MM/yyyy.
Utilizo un data time picker (DTP) para inicar la fecha inicial y la fecha final del rango de fechas deceado.
Sin embargo si selecciono 01/Jun/2016, el sistema lo tomo como 06/Ene/2016, a pesar de que tengo el formato de fecha in mi OS (win7) configurado para Costa Rica y la info en la tabla esta en el mismo formato, el sistema sigue interpretando la fecha en formato USA (MM/dd/yyyy).
Alguen me puede decir donde esta mi error? este problema me esta sacando las canas!
Gracias.
rango de fechas indicado en el SELECT, los datos en la tabla estan en formato fecha dd/MM/yyyy.
Utilizo un data time picker (DTP) para inicar la fecha inicial y la fecha final del rango de fechas deceado.
Sin embargo si selecciono 01/Jun/2016, el sistema lo tomo como 06/Ene/2016, a pesar de que tengo el formato de fecha in mi OS (win7) configurado para Costa Rica y la info en la tabla esta en el mismo formato, el sistema sigue interpretando la fecha en formato USA (MM/dd/yyyy).
Alguen me puede decir donde esta mi error? este problema me esta sacando las canas!
Gracias.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
Dim DTCierre As New DataTable
Dim DACierre As New OleDbDataAdapter
Dim m_CB As OleDbCommandBuilder
Dim VarFechaFormateada As String
If VarTipoCierre = 1 Then
DACierre = New OleDbDataAdapter("SELECT * FROM TBCierreDiario WHERE (Fecha) BETWEEN #" & CDate(DTPFechaIni.Value) & "# and #" & CDate(DTPFechaFinal.Value) & "# ORDER by Fecha", m_cn)
VarCierreMensaje = "Diarios"
End If
m_CB = New OleDbCommandBuilder(DACierre)
DACierre.Fill(DTCierre)
If DTCierre.Rows.Count = 0 Then
MessageBox.Show("No hay cierres " & VarCierreMensaje & " en el rango de fechas indicado. Por favor digite otro rango de fechas.", "Error.", MessageBoxButtons.OK, MessageBoxIcon.Stop)
ProcLimpiaPantalla()
Exit Sub
Else
Do While m_rowPosition <= (DTCierre.Rows.Count - 1)
Dim LI As New ListViewItem
Dim VarFecha1 As Date
VarFecha1 = DTCierre.Rows(m_rowPosition)("Fecha").ToString()
'-----------------------
Este codigo es solo para efecto de test
MsgBox(VarFecha1)
MsgBox(VarFecha1.ToString("dd/MM/yyyy")) en este punto me sigue mostrando la fecha en formato MM/dd/yyyy
MsgBox(VarFecha1.Month & " " & VarFecha1.Day)
'-----------------------
VarFechaFormateada = VarFecha1.ToString("dd/MM/yyyy")
LI.Text = VarFechaFormateada
LI.SubItems.Add(DTCierre.Rows(m_rowPosition)("TotalFacturas").ToString())
LI.SubItems.Add(DTCierre.Rows(m_rowPosition)("ImpuestoV").ToString())
If VarTipoCierre = 1 Then
LI.SubItems.Add(DTCierre.Rows(m_rowPosition)("TotalDiario").ToString())
End If
LVCierre.Items.Add(LI)
VarTotFacturas += DTCierre.Rows(m_rowPosition)("TotalFacturas").ToString()
VarTotImpuesto += DTCierre.Rows(m_rowPosition)("ImpuestoV").ToString()
If VarTipoCierre = 1 Then
VarTotal += DTCierre.Rows(m_rowPosition)("TotalDiario").ToString()
End If
m_rowPosition = m_rowPosition + 1
Loop
Valora esta pregunta


0