ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

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
(4,342 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
(4,341 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
(4,335 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
(4,333 Views)

sd.png

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 5 of 7
(4,297 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
(4,286 Views)

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



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
(4,271 Views)