Time Based activity

Hello, I want to run an activity inside while with system time as the condition
while(time>=2pm&&time<=3pm) { activity }
however with datetime.now.tostring(hh-mm) i can’t compare as integer and string.
is there any way to get the system time in integer format as i want to add more activities with time as condition.

grafik

Hi

Use the below the condition in your while loop

DateTime.Now > Datetime.ParseExact(“14:00”, “HH:mm”, System.Globalization.CultureInfo.InvariantCulture)

For more info on Datetime format and stuffs
usual format be like this
dd-MM-yyyy hh:mm:ss

where
dd - date
MM - month in number
MMM - month like Jan, Feb
MMMM - month like January, February
yyyy - 2019
yy-19

and in timestamp part
hh - hours in 12 hr format
HH - hours in 24 hr format
mm - minutes
ss - seconds
tt - AM or PM (if needed at last like this dd-MM-yyyy hh:mm:ss tt )

Cheers @VinnyThePooh

in addition to above find some more examples on the details like datatype and parsing along the condition oneliner (using timespans)
grafik

This was very helpful, also can i add another argument like
DateTime.Now > DateTime.ParseExact(“14:00”, “HH:mm”, System.Globalization.CultureInfo.InvariantCulture) AND DateTime.Now < DateTime.ParseExact(“17:00”, “HH:mm”, System.Globalization.CultureInfo.InvariantCulture)

1 Like

Yeah this is something to find between two timings
That is between 2 PM - 5 PM

Is there are further queries on this topic

Cheers @VinnyThePooh