Dim lastRun As DateTime Dim unixStart As DateTime Dim lastDay As DateTime Dim epochTime As Double Dim connection As SqlConnection = New SqlConnection(_SQLDEF_SMARTCONNECT) Using connection Dim command As SqlCommand = New SqlCommand(String.Format("SELECT LastRunDate FROM Map (NOLOCK) WHERE MapId = '{0}'", GlobalMapId), connection) connection.Open() Dim reader As SqlDataReader = command.ExecuteReader() If reader.HasRows Then reader.Read() lastRun = reader.GetDateTime(0).AddMinutes(-5).ToString("MM/dd/yyyy") GBL_MODIFIED = lastRun Else lastDay = DateTime.Now.AddDays(-1).ToString("MM/dd/yyyy") GBL_MODIFIED = lastDay End If reader.Close() End Using return true