SORTS DATE ARRAY (STRING DATA TYPE)
This VI will sort the Array of Dates in Ascending order and the Format of date is as Follows "MONTH/DAY/YEAR" in an String array
No Hardware's required
LabVIEW Version above LV2015
1. Open the VI
2. Feed Date info in the Date input Node in different order
3. Run the VI
4. Now you find the sorted DATE Array
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.
A few thoughts:
1. Because of the conversion through the timestamp datatype, the code breaks for any dates before 01/01/1904, as seen below. I would add some error handling that throws an error if the user adds too early a date. This is probably not a problem for most people doing data acquisition today, but it's worth noting.
2. The sorted date output also doesn't zero-pad the single-digit days and months (and it removes it if you have it on the inputs), which could be annoying if you're then going to append this date string to a file path and want those files to appear in date-order on disk.
3. If you can enforce zero padding for the month, date, and year - i.e., Jan 1, 1 would have to come in as 01/01/0001, not 1/1/1, and Feb 20, 2099 would have to come in as 02/20/2099, not 2/20/2099 - then your code can be simplified to the snippet below and would support sorting any dates from 01/01/0000 AD to 12/31/9999 AD.
4. If you can't or don't want to enforce zero padding on the inputs but DO want zero padding on the outputs, you could simplify the code to the snippet below and still get the same supported date ranges as in #3.
Cheers,
David