looping by datetime

Hi,

I am logging data to an Access database and then using vb.net to view the logged data. One column in the database is time. I need for the user to input a start time and stop time and have vb.net to display the data from that time period. Anyone have any ideas?

Thanks,
Matt

Comments

  • : Hi,
    :
    : I am logging data to an Access database and then using vb.net to
    : view the logged data. One column in the database is time. I need
    : for the user to input a start time and stop time and have vb.net to
    : display the data from that time period. Anyone have any ideas?
    :
    : Thanks,
    : Matt
    :

    Depending on the format, an SQL query will do the trick.
    Else, you're going to have to manually sort the data.

    Best Regards,
    Richard

    The way I see it... Well, it's all pretty blurry
  • Can you loop by datetime and do you have to use a certian type of loop if you can?

    Thanks
  • : Can you loop by datetime and do you have to use a certian type of
    : loop if you can?
    :
    : Thanks
    :

    Easiest is to loop through all items.

    Often something like this is used:
    [code]
    While Not rs.EOF
    ...
    End While
    [/code]
    Where rs is a RecordSet (or equivalent).

    To help you any further, could you show (part) of your code?

    Best Regards,
    Richard

    The way I see it... Well, it's all pretty blurry
  • Dim db As DAO.Database
    Dim rs As DAO.Recordset



    Private Sub Command1_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command1.Click
    db = DAODBEngine_definst.OpenDatabase("C:Documents and SettingsmkoesterMy DocumentscodeDATA LOGGING.mdb")
    rs = db.OpenRecordset("trial21122")

    Dim Time As DateTime
    Dim current As Integer
    Dim position As Integer
    Dim thrust As Integer
    Dim speed As Integer
    Dim index As Integer

    Dim startNumber As Integer
    Dim endNumber As Integer
    Dim i As Integer
    startNumber = TextBox2.Text
    endNumber = TextBox3.Text





    rs.MoveFirst()
    For i = 0 To (startNumber - 2)
    rs.MoveNext()

    Next



    rs.Move(0)

    For i = startNumber To endNumber

    Time = (rs.Fields("xtimestamp").Value)
    speed = (rs.Fields("Channel_0_User_Defined_Random_Random1").Value)
    thrust = (rs.Fields("Channel_0_User_Defined_Random_Random2").Value)
    position = (rs.Fields("Channel_0_User_Defined_Random_Random3").Value)
    current = (rs.Fields("Channel_0_User_Defined_Ramp_RampXL1").Value)


    Plot1.Channels(0).AddXY(Time, (rs.Fields("Channel_0_User_Defined_Random_Random1").Value))
    Plot1.Channels(1).AddXY(Time, (rs.Fields("Channel_0_User_Defined_Random_Random2").Value))
    Plot1.Channels(2).AddXY(Time, (rs.Fields("Channel_0_User_Defined_Random_Random3").Value))
    Plot1.Channels(3).AddXY(Time, (rs.Fields("Channel_0_User_Defined_Ramp_RampXL1").Value))
    ListBox1.Items.Add((rs.Fields("Channel_0_User_Defined_Random_Random1").Value))

    rs.MoveNext()
    On Error Resume Next

    Next i

    End

    Currently i have a for loop and it seems to work ok. However, I am plotting a historical graph. I need for the user to input a start time and end time and display the graphs for the above.

    Thanks very much for your help so far Richard

  • Well, you could create a recordset from the current using a correct SQL query. If that's not possible, you should loop through ALL items first, and select each item that meets the date criteria, and then display that set.

    Best Regards,
    Richard

    The way I see it... Well, it's all pretty blurry
  • Thanks Richard
    I believe i got it to work
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories