Hi:
 
I have this data:
 

ventas_encabezado_historico_sat Query

VEH_EMPRESA
VEH_TIENDA
VEH_FECHA
VEH_STATUS
VEH_TOTAL
VEH_HORA

DLC
T01
6/1/2003
V
30
8:31:05 AM

DLC
T01
6/1/2003
V
114.28
8:38:44 AM

DLC
T01
6/1/2003
V
63.2
8:41:13 AM

DLC
T01
6/1/2003
V
8.75
8:42:47 AM

dlc
T01
6/1/2003
V
12.35
8:50:59 AM

dlc
T01
6/1/2003
V
63.97
8:53:10 AM

DLC
T01
6/1/2003
V
10
8:54:24 AM

DLC
T01
6/1/2003
V
50.65
8:57:54 AM

DLC
T01
6/1/2003
V
36
9:01:04 AM
 
Where veh_fecha is type date, veh_hora is type date and veh_total is
double
 
And I have this code where I try to get the # of registres and a sum in
a specific date for a specific time interval (15 minutes) but the select
do not work, it returns 0 o the result of the full day, what I’m doing
wrong?
 
HORA_INICIO = TimeSerial(7, 0, 0) '7:00 am
              Do
                Cantidad_Ventas = 0
                VALOR_VENTAS = 0
                'voy a calcular los valores de atención
                strSQL = "select Count(*) as Cantidad, Sum(veh_total) as
Valor from " & _
                         "ventas_encabezado_historico_sat where " & _
                         "veh_empresa='" & EMP & "' and " & _
                         "veh_tienda='" & Tienda & "' and " & _
                         "veh_fecha=" & MakeUSDate(MAX_ESTADISTICA) & "
and " & _
                         "Veh_hora>=" & MakeUSTime(HORA_INICIO) & " And
" & _
                         "veh_hora<" & MakeUSTime(HORA_INICIO +
TimeSerial(0, 15, 0))
                Set RST = DB.OpenRecordset(strSQL)
                'ya tengo calculado los valores, los tengo que guardar
                Cantidad_Ventas = RST!Cantidad
                
                If IsNull(RST!valor) = True Then
                  VALOR_VENTAS = 0
                Else
                  VALOR_VENTAS = RST!valor
                End If
                
                RST.Close
                Set RST = DB.OpenRecordset("Select * from estad_atencion
where 1=0")
                RST.AddNew
                RST!est_empresa = EMP
                RST!est_tienda = Tienda
                RST!est_fecha = MAX_ESTADISTICA
                RST!est_hora = HORA_INICIO
                RST!est_atencion = Cantidad_Ventas
                RST!est_valor = VALOR_VENTAS
                RST.Update
                RST.Close
                HORA_INICIO = HORA_INICIO + TimeSerial(0, 15, 0)
              Loop Until HORA_INICIO > TimeSerial(22, 0, 0)
 
 
 
Function MakeUSDate(X As Variant) As String
      If Not IsDate(X) Then Exit Function
      MakeUSDate = "#" & Month(X) & "/" & Day(X) & "/" & Year(X) & "#"
End Function
 
Function MakeUSTime(X As Variant) As String
      If Not IsDate(X) Then Exit Function
      MakeUSTime = "#" & Hour(X) & ":" & Minute(X) & ":" & Second(X) &
"#"
End Function
 

-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.9.10 - Release Date: 4/14/2005
 

Reply via email to