Question : Sql Query New data at 9am only

My current query is giving me data starting at 9am - 9am(24 Hours)
 I only need to see 9am only for each day in my date range.

SELECT     FlowLogPeriod.MdbDeviceID, DeviceSummary.MeterID, convert (datetime, FlowLogPeriod.LogPeriodFlowDateTime,101), FlowLogPeriod.AP
FROM         DeviceSummary INNER JOIN
                      FlowLogPeriod ON DeviceSummary.MdbDeviceID = FlowLogPeriod.MdbDeviceID
WHERE     (DeviceSummary.MeterID = '01103-705') and (FlowLogPeriod.LogPeriodFlowDateTime >= @StartDate) AND  (FlowLogPeriod.LogPeriodFlowDateTime <= @EndDate)

Answer : Sql Query New data at 9am only

Here is an old-school example.  You would either change the hard-coded default directory or use ask the user for the directory name.

In order to calculate the StdDev, you have to make two passes through the data, first calculating the average and then the variance.
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:
55:
56:
57:
58:
59:
60:
61:
62:
Option Explicit

Public Sub stats()
  Dim intFN As Integer
  Dim strLine As String
  Dim strParsed() As String
  Dim dblSums(8 To 15) As Double
  Dim dblAvgs(8 To 15) As Double
  Dim dblVariances(8 To 15) As Double
  Dim lngCount As Long
  Dim lngColumns(1 To 4) As Long
  Dim strFilename As String
  lngColumns(1) = 8
  lngColumns(2) = 11
  lngColumns(3) = 12
  lngColumns(4) = 15
  Dim lngLoop As Long
  Const CSVpath As String = "C:\Users\Mark\Downloads\"
  '1gl-Factory-Low-SNR-Power-Level-.csv"
  
  intFN = FreeFile
  strFilename = Dir(CSVpath & "*.csv")
  Do Until Len(strFilename) = 0
    Open CSVpath & strFilename For Input As #intFN
    Do Until EOF(intFN)
      Line Input #intFN, strLine
      strParsed = Split(strLine, ",")
      '(I, L, M, N,  P) = 9, 12, 13, 15 with one origin
      For lngLoop = 1 To 4
        dblSums(lngColumns(lngLoop)) = dblSums(lngColumns(lngLoop)) + Val(strParsed(lngColumns(lngLoop)))
      Next
      lngCount = lngCount + 1
    Loop
    Close #intFN
    strFilename = Dir()
  Loop
    
  For lngLoop = 1 To 4
    dblAvgs(lngColumns(lngLoop)) = dblSums(lngColumns(lngLoop)) / lngCount
  Next
  
  strFilename = Dir(CSVpath & "*.csv")
  Do Until Len(strFilename) = 0
    Open CSVpath & strFilename For Input As #intFN
    Do Until EOF(intFN)
      Line Input #intFN, strLine
      strParsed = Split(strLine, ",")
      For lngLoop = 1 To 4
        dblVariances(lngColumns(lngLoop)) = dblVariances(lngColumns(lngLoop)) + (dblAvgs(lngColumns(lngLoop)) - Val(strParsed(lngColumns(lngLoop)))) ^ 2
      Next
    Loop
    Close #intFN
    strFilename = Dir()
  Loop
    
    Debug.Print lngCount
    For lngLoop = 1 To 4
      Debug.Print dblSums(lngColumns(lngLoop)), dblAvgs(lngColumns(lngLoop)), dblVariances(lngColumns(lngLoop)), Sqr(dblVariances(lngColumns(lngLoop)))
    Next
  
  
End Sub
Random Solutions  
 
programming4us programming4us