Is there a way to write a String variable named "12:00" that returns True if the current time is after 12:00?

Currently, there is a string variable with the value “12:00”.

I’m trying to make it return True if it is before 12:00 and False if it is after 12:00 by comparing it to the current time, but I can’t find how to apply it to a time type variable from the above text.

Also, if the variable change to “11:30” instead of “12:00”, it should be able to judge around 11:30, and if it says “13:00”, it should be able to judge around 13:00, so I can’t find a way to make it work dynamically.

Therefore, I would like to know the following three things.
1、How to apply “12:00” to today’s 12:00.
2、How to judge whether it is before or after 12:00 by comparing it with the current time.
3,If “12:00” is changed to “11:30” or “13:00”, how to judge whether it is before or after the changed time.

Thank you for reading

HI @Kirigirisu_Coin,

have you already tried using a varibale of the type DateTime? With that variabletype you can compare two DateTime variables. You can converte yout String variable to a DateTime variable and vise versa.

Hope this helps you.

have a look here:

1 Like

I knew about CDate, but I didn’t know that it could be inserted as is.
Thank you for telling me about it.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.