I have a report application developed in VB6 and Oracle 8 database. For needs that were arising, I was putting new fields and functions that complicated the query. The last one is that it was necessary to list by production date, being between 7:00:00 am of the day consulted and 06:59:00 next day (subsequent). That is, if I ask for a list dated 05/30/2018, I charge a listview with the data between 7:00:00 am on 05/30/2018 and 06:59:00 am on 05/31/2018 . As you will see in the code, it works correctly. What I need now, is that with the same query, write in the listview the date 05/30/2018, that is the production date, taking into account that the query can be several days, that is, it should be displayed in the listview each production day with the unified date. I hope the need is understood. Copy part of the code I use:
If c_porfecha Then
Dim cformato1 As String
Dim cformato2 As String
cformato1 = "dd/mm/yyyy hh:mi:ss a.m."
cformato2 = "nls_date_language=american"
fec1 = CStr(var_fecha1) & " 07:00:00 a.m."
fec2 = DateAdd("d", 1, DTPicker2.value) & " 06:59:00 a.m."
If cadenita <> "" Then
cadenita = cadenita & "AND TS_CREACION BETWEEN TO_DATE('" & fec1 & "','" & cformato1 & "','" & cformato2 & "') " & _
"AND TO_DATE('" & fec2 & "','" & cformato1 & "','" & cformato2 & "') "
titulo_reporte = titulo_reporte & "desde el " & label1(3) & " hasta el " & label1(4)
Else
cadenita = cadenita & " TS_CREACION BETWEEN TO_DATE('" & fec1 & "','" & cformato1 & "','" & cformato2 & "') " & _
"AND TO_DATE('" & fec2 & "','" & cformato1 & "','" & cformato2 & "') "
titulo_reporte = titulo_reporte & "Todos los Registros desde el " & label1(3) & " hasta el " & label1(4)
End If
cformato1 = ""
cformato2 = ""
con_where = True
End If
Set RsListado = oradatabase.dbcreatedynaset(cadenita, 0&)
If Not (RsListado.BOF And RsListado.EOF) = True Then
RsListado.MoveLast
a1 = RsListado.RecordCount
ProgressBar1.Min = 0
ProgressBar1.Max = a1
RsListado.MoveFirst
For b1 = 1 To a1
Label3 = Str(a1)
ProgressBar1.value = b1
label7 = CLng((ProgressBar1.value * 100) / ProgressBar1.Max) & " %"
Set subelemento = LvDatos.ListItems.Add(, CStr(RsListado!id) & "M", CStr(RsListado!id))
subelemento.SubItems(1) = CStr(RsListado!SECTOR)
subelemento.SubItems(2) = CStr(RsListado!AREA)
subelemento.SubItems(3) = CStr(RsListado!ISLA)
subelemento.SubItems(4) = Format(CDate(RsListado!fecha), "dd/mm/yyyy")
subelemento.SubItems(5) = Trae_Op(RsListado!OP)
RsListado.MoveNext
Next
If btnProcesar.Enabled = False Then btnProcesar.Enabled = True
Else
LvDatos.ListItems.Clear
Label3 = "0"
MsgBox "No existen datos !", vbCritical
If btnProcesar.Enabled = True Then btnProcesar.Enabled = false
End If
If titulo_reporte = "Reporte de " Then titulo_reporte = "Reporte de Todos los Registros"
Set subelemento = Nothing
LvDatos.Sorted = False ' Con esto se ordena la lista :)
RsListado.Close
Set RsListado = Nothing
Set subelemento = Nothing