Hi Team,
I need a help from you guys, got stucked to this issue for long time.
I have stored 5 dates("5 Feb"; "6 Apr"; etc..) and want convert to DateTime and validates dates are in ascending and descending order.
Kindly help me.
Convert dates from string to datetime and sort in different
-
- Posts: 254
- Joined: Tue Mar 24, 2015 5:05 pm
- Location: Des Moines, Iowa, USA
Re: Convert dates from string to datetime and sort in different
Date.TryParse will get you a date object from a string object.
The next bit can be more tricky depending on what you want to do. If you want to just compare two dates you can use the compare method of the date object. However if you want to sort a list of dates, you'll probably need some fancy code.
Code: Select all
Public Shared Function StringToDate(ByVal dateAsString As String) As Date
Dim myDate As Date
Date.TryParse(dateAsString, myDate)
Return myDate
End Function
Doug Vaughan
Re: Convert dates from string to datetime and sort in different
Hi,
As for validating datetime order, I would use the code described here:
https://stackoverflow.com/questions/180 ... st-by-time
I would create a copy of the original list of dates, sort the duplicated list using the above code and then simply compare both lists if they are the same. If not, the sorting of original list of dates is most probably incorrect
As for validating datetime order, I would use the code described here:
https://stackoverflow.com/questions/180 ... st-by-time
I would create a copy of the original list of dates, sort the duplicated list using the above code and then simply compare both lists if they are the same. If not, the sorting of original list of dates is most probably incorrect

Last edited by odklizec on Mon Nov 13, 2017 12:02 pm, edited 1 time in total.
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
Ranorex explorer at Descartes Systems
Please add these details to your questions:
- Ranorex Snapshot. Learn how to create one >here<
- Ranorex xPath of problematic element(s)
- Ranorex version
- OS version
- HW configuration
Re: Convert dates from string to datetime and sort in different
Thank you guys for the reply 

-
- Posts: 254
- Joined: Tue Mar 24, 2015 5:05 pm
- Location: Des Moines, Iowa, USA
Re: Convert dates from string to datetime and sort in different
I should've figured there was a sorting solution in Linq.odklizec wrote:Hi,
As for validating datetime order, I would use the code described here:
https://stackoverflow.com/questions/180 ... st-by-time
I would create a copy of the original list of dates, sort the duplicated list using the above code and then simply compare both lists if they are the same. If not, the sorting of original list of dates is most probably incorrect
+1 for you!
Doug Vaughan