I am trying to figure out how to see the current time is between certain times that the user has entered.
I have the following code which works if the time is between 00:01 and 23:59, however if the user enters a time, such as, 20:00 and 05:00 then the below code does not work. Which I guess is because we are now spanning times that exist within 2 days and not one.
What I want to do is as I said above, detect if the current time is between a timespan of, say, 20:00 to 05:00. So for instance this could be Tuesday 20:00 (8PM) and Wednesday 05:00 (5AM), however I can not figure out how to do this as my users could also enter a time like 14:00 to 18:00 on the same day, so cannot use greater than and less than on the times.
Any help would really be appreciated.
Thanks
Simon
I have the following code which works if the time is between 00:01 and 23:59, however if the user enters a time, such as, 20:00 and 05:00 then the below code does not work. Which I guess is because we are now spanning times that exist within 2 days and not one.
What I want to do is as I said above, detect if the current time is between a timespan of, say, 20:00 to 05:00. So for instance this could be Tuesday 20:00 (8PM) and Wednesday 05:00 (5AM), however I can not figure out how to do this as my users could also enter a time like 14:00 to 18:00 on the same day, so cannot use greater than and less than on the times.
VB.NET:
dim inTimeSpan as boolean = DateTime.Now.TimeOfDay >= CISData.Instance.ThreadStart AndAlso DateTime.Now.TimeOfDay <= CISData.Instance.ThreadEnd
Any help would really be appreciated.
Thanks
Simon