Urgent help on reading data from excel

I want to read the time from excel and then display in message box that these employees came late to the office… ? What will be syntax for the IF condition part??

Can you show us how the excel file look like? ( try to upload it ) in order for us to see


For instance, it has a column name as ‘In Time’ and values are ‘9:00:00’, ‘9:15:00’… so I want that in if condition I should be able to check if time is > 9:00:00… what is the syntax for this?


Thanks for your reply. My data has two different columns for Date and Time. Attaching data set snapshot for your reference.

Please suggest.

1 Like

I tried these two logics in If condition, but no luck !

  1. DateTime.Parse(row.Item(“In Time”).ToString) > DateTime.Parse(“09:00:00”)

  2. (DateTime.Parse(row(“InTime”)).ToString(“hh:mm:ss”)).Subtract(DateTime.Parse(“09:00:00”).ToString(“hh:mm:ss”))

1 Like

I will try to do the following:

  1. make new string _dateTimeString = date + " " + inTime
  2. convert _dateTimeString var to dateTime type like in the following link- > Convert a string to Date time variable

Good luck

1 Like

Hey @Jasmeet_Kaur

Hope you are doing well,

you can try this

  • (DateTime.ParseExact(DateTime.Now.ToString(“MM/dd/yyyy HH:mm:ss”), “MM/dd/yyyy HH:mm:ss”, System.Globalization.CultureInfo.InvariantCulture)-DateTime.ParseExact(Cdate(row(“In Time”).ToString).ToString(“HH:mm:ss”), “HH:mm:ss”, System.Globalization.CultureInfo.InvariantCulture)).TotalHours.ToString()