I would like to compare two American dates and identify whether one is greater than the other. I am encountering two issues:
The date the automation gets from a SharePoint site is in American format MM/dd/yyyy hh:mm
I would like to convert the string to yyyy/MM/dd hh:mm so I am able to compare the two dates to identify which is the greatest date. The automation I have developed is below:
The first issue I have is - the Proxy does not seem to put the date into the format of yyyy/MM/dd and keeps it as yyyy/dd/mm for instance 03/08/2019 I wish to convert to 20190308 but it is converting to yyyy/dd/MM.
The second issue I am having is it does not recognise 06/14/2018 as a date therefore when passed into the datetime variable it causes an error suggesting that this is a date. I am based in U.K so my locale is English.
I would use DateTime.TryParse. I believe this will work for you. There are overloaded methods that accept a specific format if your system settings cause it to fail for other locales. I have attached a sample solution. To add the static methods;
Right-click on the Toolbox in an empty area
Select "Choose items"
Select the "Pega Robotics Static Members" tab
"Select the "From Global Assembly Cache" radio button
Select the "mscorlib" assembly and locate the "DateTime" node
Check the check box next to each method you want to add to the Toolbox and click "Ok"
Thanks for your help! Unfortunately the above format the dates into the same format YYYY/MM/DD HH:MM, therefore I have taken the approach of extracting the elements of the date using the split function in the StringUtils and manually adjusting the format. Please see the solution I have used below. (I am aware this is not the best way but has helped me resolve the issue hence the posting :) )