How to order time cells in access after midnight?

1

I am using MS Access 2007 on Windows 2010 and have an Access DB where I have to order some records by time (hours:minutes).

The values in the cells start from 5:00 AM until the 1:00 AM. The problem is that I need that the values from midnight to 1:00AM must be at the end list.

Ale

Posted 2018-01-08T15:34:22.020

Reputation: 704

Answers

0

The solutions is to set the format in the MS access as date/hour and format hh:nn;@ (eventually hh:nn:ss;@).

If your data list in Access is not ordered as you need you can solve in this way:

  1. copy/export the list in MS Excel
  2. set the format in MS Excel as in the picture below (hh:mm;@)
  3. correct only the values after midnight as 24:MM:SS
  4. set in MS Access new format as in the second picture below (hh:nn;@)
  5. copy/import new data from MS Excel

picture1_excel_format picture2_access_format

images come from my regional version of MS Access and MS Excel

Ale

Posted 2018-01-08T15:34:22.020

Reputation: 704

1

I would suggest making a query of your table with a calculated column which is just the time column minus 1 hour. Then you can sort based on this calculated column and the 1:00am times will all sort to the bottom. The sorting column does not need to be displayed in any of your forms or reports, just used for the sort.

techturtle

Posted 2018-01-08T15:34:22.020

Reputation: 8 059

I would like to find a solution in the same column, if is it possible, because I have several queries and reports linked to this list – Ale – 2018-01-09T09:26:46.517

1I think the only way you could sort them as you want--with only the original column--is if it also contains the date. If you're just trying to get them to appear that way in a form or report, then you could possibly do it in the code, but it is likely to be complicated and is definitely beyond the scope of something that could be provided here. – techturtle – 2018-01-09T13:04:59.307

1

Create a Query with the following SQL:

SELECT * FROM myTable ORDER BY TimeValue(DateAdd("h",-1,[myTime]));

In the above, change myTable to the name of your table, and myTime to the name of the field containing your time value.

Lee Mac

Posted 2018-01-08T15:34:22.020

Reputation: 763