Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stripping time from datetime in Sort

Tags:

excel

vba

I'm working in VBA for Excel. Got the following raw data:

**TIME**                  **PRICE**
04-02-2013  10:36:00        560
04-02-2013  12:40:00        600
03-02-2013  16:10:00        612

I need an efficient and trustworthy method of stripping the time from the datetime TIME and then sorting on TIME NEWEST first and PRICE DESCENDING second. Desired output:

**TIME**                  **PRICE**
04-02-2013                  600
04-02-2013                  560
03-02-2013                  612

Simply changing the column format and forcing DD-MM-YYYY does not work. I've tried a few things myself, for example by converting the column to TEXT and stripping the time by removing every thing after the decimals in the displayed datetime-values, but it didn't work out. I hope you can help me!

like image 488
KHH Avatar asked Nov 23 '25 13:11

KHH


1 Answers

Simply changing the column format and forcing DD-MM-YYYY does not work.

Since like your date/time is stored as text. Try this

=TEXT(A1,"DD/MM/YYYY")

enter image description here

FOLLOWUP FROM COMMENTS

I am able to get the desired out by simple sorting?

enter image description here

like image 180
Siddharth Rout Avatar answered Nov 26 '25 05:11

Siddharth Rout