Sorting Date and Time

markster

Well-known Member
Joined
May 23, 2002
Messages
579
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hello there

A column in my spreadsheet contains the date and time of transaction in the following format:

2021.05.10 01:00:29

There's 20,000 lines and i need to sort by date and time but i can't get it to work using the sort function - does anyone have any ideas?

Thanks
Mark

2021.05.10 01:00:29
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Hi,​
maybe 'cause that's just text rather than date ! Check with ISNUMBER worksheet function : TRUE means date but FALSE is text …​
 
Upvote 0
Hi Markster,

=SUBSTITUTE(B2,".","/")+0
Will return 44326.042 which represents 10 May 2021 at 1am and 29 seconds which you can then sort.
 
Upvote 0
The sort should work OK.
to secure some help, you need to provide some information

- is the data text or numbers
- is the information real data or a formula

Please post an extract of your data with the forum's XL2BB.
 
Upvote 0
Hey just as a follow up to this I want to categorise the dates and times into 2 time periods as follows:

Any transactions falling into time periods

14:30 to 21:15
21:16 to 14:29

My time data is in column B time period in column C so I need a formula in Column C that would return the relevant time period eg.

14:45 would be in 14:30 to 21:15
21:20 would be in 21:16 to 14:29

Thanks again in advance for your help.

Cheers Mark
 
Upvote 0
Like this?

Markster.xlsx
ABC
1Date/TimeAs number for sortingCategory
22021.05.10 01:00:2944326.0422
32021.05.10 14:00:2944326.583672
42021.05.10 14:00:3044326.583682
52021.05.10 14:30:0044326.604171
62021.05.10 21:00:2944326.875341
72021.05.10 14:00:2944326.583672
82021.05.10 19:00:2944326.7921
92021.05.10 11:00:2944326.458672
102021.05.10 05:00:2944326.208672
Sheet1
Cell Formulas
RangeFormula
B2:B10B2=SUBSTITUTE(A2,".","/")+0
C2:C10C2=IF(AND(TIMEVALUE(RIGHT(A2,8))>=TIME(14,30,0),TIMEVALUE(RIGHT(A2,8))<=TIME(21,15,0)),1,2)
 
Upvote 0
Like this?

Markster.xlsx
ABC
1Date/TimeAs number for sortingCategory
22021.05.10 01:00:2944326.0422
32021.05.10 14:00:2944326.583672
42021.05.10 14:00:3044326.583682
52021.05.10 14:30:0044326.604171
62021.05.10 21:00:2944326.875341
72021.05.10 14:00:2944326.583672
82021.05.10 19:00:2944326.7921
92021.05.10 11:00:2944326.458672
102021.05.10 05:00:2944326.208672
Sheet1
Cell Formulas
RangeFormula
B2:B10B2=SUBSTITUTE(A2,".","/")+0
C2:C10C2=IF(AND(TIMEVALUE(RIGHT(A2,8))>=TIME(14,30,0),TIMEVALUE(RIGHT(A2,8))<=TIME(21,15,0)),1,2)
So - I have changed a little bit so have DATE ONLY in Cell A2 TIME ONLY in B2. So when use the formula referencing B2 it just returns and error. Think it's my fault for splitting it out - can the formula be adapted? Thanks Mark


Like this?

Markster.xlsx
ABC
1Date/TimeAs number for sortingCategory
22021.05.10 01:00:2944326.0422
32021.05.10 14:00:2944326.583672
42021.05.10 14:00:3044326.583682
52021.05.10 14:30:0044326.604171
62021.05.10 21:00:2944326.875341
72021.05.10 14:00:2944326.583672
82021.05.10 19:00:2944326.7921
92021.05.10 11:00:2944326.458672
102021.05.10 05:00:2944326.208672
Sheet1
Cell Formulas
RangeFormula
B2:B10B2=SUBSTITUTE(A2,".","/")+0
C2:C10C2=IF(AND(TIMEVALUE(RIGHT(A2,8))>=TIME(14,30,0),TIMEVALUE(RIGHT(A2,8))<=TIME(21,15,0)),1,2)
 
Upvote 0
Hey really sorry but I've split out the date and time so Date only is in A2 and Time Only in B2. So when I used the formula and relate to. B2 it doesn't work - can it be adapted? Sorry again. thanks Mark
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,693
Members
448,979
Latest member
DET4492

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top