How do I handle the format of Date and other data formatting using exception handling?


#1

How do I handle the format of Date and other data formatting using exception handling?
Say date format should be in DD-MM-YYYY. Incase the format is different, how do i check that and throw exception?

Similarly a particular customer ID is always numeric, how do i put those validations using uipath??


#2

For date, I would use the same way I would in real life: check if what I think is the month section goes above 12. So if I have date 07/24/2018 I know it’s MM/dd/yyyy because the middle number is larger than 12. Using a split activity on the string (or a substring if the format is always the same), you can split that string into 3 parts based on /, and check if the middle part is larger than 12.

For customer ID you can use visual basic to check if the string contains only numbers. Something like microsoft.visualbasic.information.isnumeric(your_string).