Help - Hours intervals problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mic docw@globetrotter.net

    #1

    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

Working...