How to Sort by Date and Time in Excel (4 Useful Methods)

 

Let’s have a look at our sample dataset. Here, the Order ID of products is given along with their Delivery Date, Delivery Time, and Price. We’ll sort the dataset based on Delivery Date and Time.

excel sort by date and time


Method 1 – Using the Direct Excel Drop-down Option to Sort Date and Time

  • Select the whole dataset.
  • Click on the Home tab, go to the Sort & Filter toolbar, and select Filter
  • You can also use Ctrl + Shift+ L.

Using Direct Drop-down Option

  • You’ll get the drop-down arrow for each heading of the dataset like this.

excel sort by date and time

  • To sort the dates, click on the drop-down arrow of the Delivery Date
  • Choose the Sort Oldest to Newest if you need to sort the dataset chronologically.
  • Press OK.

  • The table will be sorted based on the Delivery Date cells chronologically.

  • Click on the heading of the Delivery Time and choose Sort Smallest to Largest.

excel sort by date and time

  • You’ll get the following sorted dataset.

  • This overwrites the first sort, so you can sort either by date or by time.

Read More: How to Sort Dates in Chronological Order in Excel


Method 2 – Applying the Custom Sort Option to Sort Date and Time in Excel

  • Select the dataset.
  • Click on the Home tab and go to the Sort & Filter toolbar, then select Custom Sort.

Utilizing Custom Sort Option

  • A Sort dialog box will appear.
  • Select the Delivery Date from the heading in the Sort by box.
  • Choose the Oldest to Newest in the Order.

excel sort by date and time

  • Click on the +Add Level.
  • Specify the Delivery Time as the heading, and Smallest to Largest as Order.
  • Click OK.

  • Here’s the output for our sample dataset.

excel sort by date and time


Method 3 – Converting Date-Time to Numbers and Sorting in Excel

Let’s get the Delivery Date and Time provided together simultaneously. We can sort based on both.

  • Insert the following formula in the E5 cell and press Enter.
=C5+D5

C5 is the Delivery Date and D5 is the Delivery Time.

Converting Date-Time to Number and Sorting

  • Press Enter.
  • Use the Fill Handle by dragging down the cursor while holding the right-bottom corner of the E5 cell.

excel sort by date and time

  • We’ll get the outputs like this.

  • Insert the following formula in the F5 cell like this.
=VALUE(E5)

  • Press Enter and use the Fill Handle.

  • Select the dataset.
  • Go to Home and click Editing.
  • Choose Sort & Filter and select Custom Sort.

excel sort by date and time

  • If you don’t select the whole dataset, this warning will appear. Select Expand the selection and click Sort.

  • The Sort window will appear.
  • Choose Sorted Delivery Date-Time in the Sort by box and Smallest to Largest in the Order box.
  • Click OK.

excel sort by date and time

  • We’ll get the outputs in Column F in a different format. Right-click the data of Column F and select Format Cells.

  • A Format Cells window will appear.
  • Go to Number, select Custom, and choose m/d/yyyy h:mm in the Type field.
  • Click OK.

excel sort by date and time

  • We’ll see the output like this.

Read More: How to Sort by Date in Excel


Method 4 – Applying Excel MID and SEARCH Functions to Sort by Time and Date

The MID function returns the middle number from a given text string. The syntax of the function is.

=MID (text, start_num, num_chars)

The arguments are-
text – The text to extract from.
start_num – The location of the first character to extract.
num_chars – The number of characters to extract.

The SEARCH returns the position of the first character of find_text inside within_text.

=SEARCH (find_text, within_text, [start_num])

The arguments are
find_text – The text to find.
within_text – The text to search within.
start_num – [optional] Starting position in the text to search. Optional, defaults to 1.

  • Apply the following formula in D5:
=MID(C5,SEARCH(", ",C5,1)+1,50)

Here, C5 is the Delivery Day-Date-Time.

Applying MID and SEARCH Functions

  • Press Enter.
  • Use the Fill Handle.

  • Use this formula in the E5 cell to change Delivery Date-Time into a number using the VALUE function in order to sort them later.
=VALUE(D5)

excel sort by date and time

  • Press Enter and use the Fill Handle.

  • To sort the values chronologically, copy cells E5:E16 and paste those to F5.

  • Select the cells and Sort them and then use the Format Cells option to give the specific format.
  • You’ll get the output like this.

excel sort by date and time

Read More: How to Sort Dates in Excel by Month and Year


Things to Remember

  • Excel stores date as serial numbers. If you get your desired output as a serial number, change the format using the Format Cells option.
  • Be careful about the sorted data whether the whole dataset is changed or not.

Download the Practice Workbook



<< Go Back to Sort by Date in Excel | Sort in Excel | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Md. Abdul Kader
Md. Abdul Kader

MD. ABDUL KADER is an engineer with a talent for Excel and a passion for VBA programming. To him, programming is like a time-saving wizard, making data manipulation, file handling, and internet interactions a breeze. His skill set extends to SWM, GIS, RS, and SPSS. He holds a B.Sc in Urban & Regional Planning from Chittagong University of Engineering and Technology and has shifted to become a content developer. In this role, he crafts technical content centred around... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo