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
(1,817 Views)

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

Pazhanivel Thiruvenkadam,
CertifiedLabVIEWArchitect|| CertifiedTestStandDeveloper,
Currently able to Access LV2015&LV2017
0 Kudos
Message 2 of 7
(1,816 Views)

 

DateSorting.png 

Try this, May be others can suggest easy conversion.

Pazhanivel Thiruvenkadam,
CertifiedLabVIEWArchitect|| CertifiedTestStandDeveloper,
Currently able to Access LV2015&LV2017
Message 3 of 7
(1,810 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
0 Kudos
Message 4 of 7
(1,808 Views)

sd.png

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