TomHardy
TomHardy

Reputation: 33

MS Access Sort Access report by start of string

Hi all I have a question, I have a report where I have some indicators about breakdown of machines. I have there a column where there is a time of the breakdown.

The problem is the company works on 2 shifts a day. Day shift and Night shift. The day shift starts at 7AM and end at 7PM and the night shift continues.

The problem is I want to start the sorting from the 7AM and go on... like this

7AM

8AM

9AM

10AM

.

.

.

.

23PM

24PM

1AM

2AM

3AM

4AM

5AM

6AM

Can someone halp me?

Upvotes: 0

Views: 49

Answers (2)

Robert Patrician
Robert Patrician

Reputation: 322

In your data source for the report, you could build a custom value for what shift something is on and then sort by that. For example

Shift: If(BreakdownTime>=23:00 or <=0700,"night","Day")

Then in your report you add the "Shift" field as a grouping.

Upvotes: 1

Gustav
Gustav

Reputation: 55961

Shift the times to appear as starting at Midnight:

DateAdd("h", -7, [ShiftStartTime])

An expression like this, you can sort the report by.

If text time, convert to Date:

DateAdd("h", -7, CDate([ShiftStartTime]))

Upvotes: 2

Related Questions