From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

sort date

 Hi all , 

 

i am having the dates like 5/29/2018 in array ( month / date / year ) [ reading from the access database ]

 

i need to sort the dates in a correct order . used sort array option , but not getting in a right order. pls, see attached image here . 

any other options?

0 Kudos
Message 1 of 7
(2,963 Views)

Its always good to share code(VI)/Code snippet, Nothing can be understood by attaching image of FP.

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 2 of 7
(2,962 Views)

 

DateSorting.png 

Try this, May be others can suggest easy conversion.

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
Message 3 of 7
(2,956 Views)

They are ordered as strings. You need to convert strings to Timestamps before sorting, using Scan From String with format string %<%m/%d/%y>T

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 4 of 7
(2,954 Views)

sd.png

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 5 of 7
(2,918 Views)

Easiest way if you have control is to start with dates in ISO 8601 format.  Then you can just remove the "/" and sort as numbers.

 

Reference: https://xkcd.com/1179/

0 Kudos
Message 6 of 7
(2,907 Views)

My solution is similar to Paul's.  It just avoids the conversion back into a string.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 7 of 7
(2,892 Views)