troubleshooting Question

Help - Hours intervals problem

Avatar of scml
scml asked on
Visual Basic.NET
2 Comments1 Solution319 ViewsLast Modified:

I'm struggling with the following problem and after days I feel it's time to seek help.

I have 2 datetime (time) variables:

Dim BeginHour As DateTime
Dim EndHour As DateTime

Dim Period1, Period2, Period3 As String

I have these periods:

00:00 to 07:00 'night
07:00 to 19:00 'day
19:00 to 24:00 'evening

I have to calculate:
1)How many periods in the preceding list BeginHour and EndHour cover.
2)Associate different strings to each period covered:

BeginHour = "23:00:00"
EndHour = "01:00:00"

In that case:
Period1 = "evening"
Period2 = "night"
Period3 = ""

But it's really with the following that I have problems:

BeginHour = "01:00:00"
EndHour = "23:00:00"

In that case, result should be:
Period1 = "night"
Period2 = "day"
Period3 = "evening"

I can't figure out how to do it and this is where I need your help.



Mike Tomlinson
High School Computer Science, Computer Applications, Digital Design, and Mathematics Teacher
Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros