Query to identify if a time period is between times that pass through midnight? (3 Viewers)

keeper

Registered User.
Local time
Today, 09:46
Joined
Jun 2, 2016
Messages
16
Yes I changed the query date format to match mm/dd/yyyy hh:nn

Still all fail

Checking the code it refers to ChangeStart, in_ChangeEnd however the DB has
Change_Start & Change_End which I can easily change.

Should both these lines refer to ChangeStart??
dt_MustStartBy = CDate(DatePart("m", in_ChangeStart) & "/" & DatePart("d", in_ChangeStart) & "/" & DatePart("yyyy", in_ChangeStart) & " " & in_DayStart)
dt_MustEndBy = CDate(DatePart("m", in_ChangeStart) & "/" & DatePart("d", in_ChangeStart) & "/" & DatePart("yyyy", in_ChangeStart) & " " & in_DayEnd)
' sets specific required start and end date/times

Many Thanks
 

plog

Banishment Pending
Local time
Today, 11:46
Joined
May 11, 2011
Messages
11,658
Yes they should. The next line in that code moves dt_MustEndBy to the next day in case the timespan goes over midnight, so that is correct.

Can you post back the database you have?
 

keeper

Registered User.
Local time
Today, 09:46
Joined
Jun 2, 2016
Messages
16
here you go...
 

Attachments

  • db.zip
    34 KB · Views: 58

plog

Banishment Pending
Local time
Today, 11:46
Joined
May 11, 2011
Messages
11,658
Here's a screenshot of my results from your database:
 

Attachments

  • Capture.PNG
    Capture.PNG
    21.6 KB · Views: 76

keeper

Registered User.
Local time
Today, 09:46
Joined
Jun 2, 2016
Messages
16
Strange , date format issue somewhere?
Although I set the query to mm/dd/yyyy hh:nn to match yours.
 

Attachments

  • Capture.PNG
    Capture.PNG
    22.2 KB · Views: 76

keeper

Registered User.
Local time
Today, 09:46
Joined
Jun 2, 2016
Messages
16
Ok, now I understand, I changed the code to -
dt_MustStartBy = CDate(DatePart("d", in_ChangeStart) & "/" & DatePart("m", in_ChangeStart) & "/" & DatePart("yyyy", in_ChangeStart) & " " & in_DayStart)
dt_MustEndBy = CDate(DatePart("d", in_ChangeStart) & "/" & DatePart("m", in_ChangeStart) & "/" & DatePart("yyyy", in_ChangeStart) & " " & in_DayEnd)

This now matches that date format in the table as dd/mm/yyyy hh:nn.

Our results now match, many thanks for you help......
 

plog

Banishment Pending
Local time
Today, 11:46
Joined
May 11, 2011
Messages
11,658
Good, glad you got it. Date formats can be a pain.
 

Users who are viewing this thread

Top Bottom