With references to PISDK and PISDKCommon type libraries, this approach using the IPIData2 interface would work for one tag at a time.
Code:Private Sub SampledDataTest()
Dim srv As Server
Dim pt As PIPoint
Dim pdata As PIData
Dim ipid2 As IPIData2
Dim vals As PIValues
Dim startTime As String, endTime As String, duration As String
Dim i As Integer
startTime = "28-Jan-2011 12:45:00" ' could use t for today at 00:00:00
endTime = "*" ' could use * for current time
duration = "30m" ' calculation interval
Set srv = Servers("MYPISERVER")
If srv.Connected = False Then
srv.Open
End If
Set pt = srv.PIPoints("MYPITAG") ' get tag
Set pdata = pt.Data
Set ipid2 = pdata ' get pointer to IPIData2 Interface
Set vals = ipid2.InterpolatedValues2(startTime, endTime, duration)
For i = 1 To vals.Count
Debug.Print Format(vals(i).TimeStamp.LocalDate, "dd-MMM-yyyy hh:mm:ss"), " ", vals(i).Value
Next i
Set vals = Nothing
Set ipid2 = Nothing
Set pdata = Nothing
Set pt = Nothing
Set srv = Nothing
End Sub
After running this against a real server and tag, the following was written to the debug window:
Code:28-Jan-2011 12:45:00 5144
28-Jan-2011 13:15:00 5148
28-Jan-2011 13:45:00 5147
28-Jan-2011 14:15:00 5147
I used the format statement to get the timestamps to appear the way I wanted. I'm sure you will want to see it a little differently, but hopefully this will help.