Avatar of scml
scml
 asked on

Help - Hours intervals problem

Hi,

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:

Example:
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.

Thanks,

ML









Visual Basic.NET

Avatar of undefined
Last Comment
scml

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Mike Tomlinson

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
scml

ASKER
Hi Idle_Mind !

Nice job ! And super quick !

Thanks,

ML
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck