Compare Time string with DateTime

Hey! I have two strings, one will contain “-text- … 2PM …-text-” and the other “-text- … 10AM …-text-”.
I want my bot to check the current time, and if right now it’s 2pm or later I want to take the 2 pm string, but if right now it’s earlier than 2pm I want to keep the 10am string.
I just want to know how to compare the 2pm and 10am strings with Now.Date.

Thanks !

Hi, I don’t get it… How are you comparing the 2PM string?
This expression: cdate(Now.ToString(“hh ttt”)) is not doing anything

Hey sorry thats my mistake

Instead of hh ttt put 2 PM


We can extract time string (like 2PM or 10AM) from your original string as the following expression.

 s = System.Text.RegularExpressions.Regex.Match(text,"[12]?[0-9][AP]M").Value

Then we can compare it with now as the following expression.