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.

3 Answers 3

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.

2
  • 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
    Jan 9, 2018 at 9:26
  • 1
    I 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
    Jan 9, 2018 at 13:04
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.

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .