title: How to read date and time from database and compare it to the system date and time
body: <p>I am working on a project using vb and one of my forms has to display the current active reminders (reminders that haven't hit their deadline yet) into a datagridview and I have another datagridview for reminders that are past the deadline. The date and time along with reminder information is saved into my access database and I want to read the date and time from database and compare it to the system date and time and then display the reminder information.</p>
  <p>This is how my form looks like; the top datagridview is for current reminders and the bottom one is for past/out of date reminders:</p>
  <p><img src="https://i.stack.imgur.com/IEub7.png" alt="The top datagridview is for current reminders and the bottom one is for past/out of date reminders" /></p>
  <p>This the code for my form and what I’ve tried:</p>
  <pre><code>Imports System.Data.OleDb
  
  Public Class frmReminderInfo
  
      Private Sub frmReminderInfo_Load(sender As Object, e As EventArgs) Handles MyBase.Load
          DisplayCurrentReminders()
      End Sub
  
      Private Sub DisplayCurrentReminders()
          Dim ReminderDateTime As Date
          Dim CurrentDateTime As Date
          CurrentDateTime = Date.Now
          CurrentDateTime = FormatDateTime(Date.Now, DateFormat.GeneralDate)
          ReminderDateTime = FormatDateTime(ReminderDateTime, DateFormat.GeneralDate)
          If DbConnect() Then
              DgvCurrentReminders.Rows.Clear()
              Dim SQLCmd As New OleDbCommand
              With SQLCmd
                  .Connection = cn
                  .CommandText = &quot;SELECT ReminderDate FROM TblReminder &quot;
  
                  Dim rs As OleDbDataReader = .ExecuteReader()
                  While rs.Read
                      ReminderDateTime = (rs(0).ToString)
                  End While
              End With
          End If
          cn.Close()
          If CurrentDateTime = ReminderDateTime Then
              Dim SQLCmd As New OleDbCommand
              With SQLCmd
                  Dim rs As OleDbDataReader = .ExecuteReader()
                  While rs.Read
                      Dim NewStockRow As New DataGridViewRow()
                      NewStockRow.CreateCells(DgvCurrentReminders)
                      NewStockRow.SetValues({rs(&quot;ReminderID&quot;), rs(&quot;CustomerName&quot;), rs(&quot;DeviceInfo&quot;), rs(&quot;RepairPrice&quot;), rs(&quot;ReminderDate&quot;)})
                      NewStockRow.Tag = rs(&quot;ReminderID&quot;)
                      DgvCurrentReminders.Rows.Add(NewStockRow)
                  End While
                  rs.Close() 
              End With
          End If
          cn.Close()
  
      End Sub
  End Class
  </code></pre>