Need to have IF statement also only go if the time is after or before 2PM

What I need to do is also have the IF statement work on a time as well. For example if it is after 2 or before 2pm. This way there is no dupicated message being sent out

using System;
using System.Management;
using System.Management.Instrumentation;
using System.Xml;
using System.IO;
using System.Collections;
using Microsoft.Win32;
using QTI.Monitor.Configuration;

namespace Q.M.T
{
      /// <summary>
      /// Tell the central server the date of when the Customer  
      /// last rebooted the PC.  
      /// </summary>
      public class TaskPCLastReboot : TaskInterface
      {
            /// <SUMMARY> </SUMMARY>
            public void DoTask(XmlNode xmlNode, ref int iSeverityLevel,
                  ref String[] sValues, ref String[] sDetails)

            {
                  //system date need to see if last reboot was today or yesterday after
                  //client last ran checks.
                  System.DateTime today = System.DateTime.Today;
                  System.DateTime daybefore = today.AddDays(-1);
      
                  try
                  {
                        //This is the actual search to get the restart date from the
                        //operating system
                        string ConfigNamespace = @"\\.\root\cimv2";
                        string query = "select * from Win32_OperatingSystem";

                        ManagementObjectSearcher searcher = new
                              ManagementObjectSearcher( ConfigNamespace, query );
                              
                        ManagementObjectCollection collection = searcher.Get();

                        DateTime bootup;      
                        foreach (ManagementObject item in collection)
                        {
                             string DMTF= item.Properties["LastBootUpTime"].Value.ToString();
                              bootup = ManagementDateTimeConverter.ToDateTime(DMTF).Date;

                              //Compare dates to see if it was today before the 8am Client runs
                              //or if it was yesterday after the Client ran
                              if (bootup == daybefore) //and time after 2pm
                              {
                                    post message if time after 2pm

                              }
                              else if (bootup == today)//and time before 2pm
                              {
                                    post message if time before 2pm
                              }
                  
                        }
                        searcher.Dispose();
                  }
                  catch (Exception e)
                  {
                      System.Diagnostics.EventLog.WriteEntry(this.ToString(),
                        ERROR.FAILED + e.ToString(),
                              System.Diagnostics.EventLogEntryType.Error);
                  }
            }
            
            public  string GetMsgId() {return m_sMsgId;}
            public  int GetMsgNum() {return m_iMsgNum;}
            private static string m_sMsgId = MESSAGETYPES.LAST_PC_RESTART_MONITOR;
            private static int m_iMsgNum = MESSAGENUMBERS.LAST_PC_RESTART_MONITOR;
      }
}
LVL 2
NewMom2BrandonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rcarlanCommented:
                         bootup = ManagementDateTimeConverter.ToDateTime(DMTF);

                         //Compare dates to see if it was today before the 8am Client runs
                         //or if it was yesterday after the Client ran
                         if (bootup.Date==daybefore && bootup.hour>=14) // bootup yesterday after 2pm
                         {
                              post message if time after 2pm

                         }
                         else if (bootup.Date==today && bootup.hour<14) // bootup today before 2pm
                         {
                              post message if time before 2pm
                         }
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
NewMom2BrandonAuthor Commented:
I did get this error

'System.DateTime' does not contain a definition for 'hour'
0
NewMom2BrandonAuthor Commented:
got it fixed...sorry!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.