How to check given date is in MM/DD/YYYY format



I am getting date from excel and just I want to check that given date is in MM/DD/YYYY format or not?

If date is 30/31/2018 then return false.
If date is 04/11/2018 then return true.

Please help me.


Neeraj Yadav


Is it stored in excel as a date, or as text?

Depending on format, you can convert it to a datetime variable, then specify whatever format you’d like. Your example would be datetime.tostring(“MM/dd/yyyy”)


as a date


UiPath is pretty good about recognizing dates in excel as actual dates. Just save the range as a datatable (the date values will be stored as datetime in the table), or save the cell directly as a datetime variable. Then you can use it throughout the rest of your workflow with the format you need


Hi Dave,

Just I want to check the date value as in below given example.

If date is 30/31/2018 then return false.
If date is 04/11/2018 then return true.


Hi @neerajmca5,

string inputString = “2000-02-02”;
DateTime dDate;

if (DateTime.TryParse(inputString, out dDate))
    String.Format("{0:d/MM/yyyy}", dDate); 
    Console.WriteLine("Invalid"); // <-- Control flow goes here

Refer this



But this concept is not working in uipath.


Again, since you’re getting the date from excel, just use date.tostring(MM/dd/yyyy) in your workflow. That will always be in the format you’re looking for.

For a different use case where you are getting the date in string format already, you should use the datetime.tryparse as @arivu96 has written out and linked. Note that he is writing actual code rather than using the UiPath workflow. If you want to copy+paste you can do it in an invoke code activity. Otherwise, you can recreate it using standard activities such as If activity, along with an assign activity.


Sharing this from my past learning,

Why it didn’t work in Assign/IF activity?

How can we resolve ? Existing sample for Double.TryParse

Solution: Use TryParseExact/TryParse in Invoke Code/Method

Date_TryParseExact_InvokeMethod.xaml (13.5 KB)

Note: You can also use TryParse for your requirement

MSDN References:

  1. DateTime.TryParse Method (String, DateTime)
  2. DateTime.TryParseExact Method (String, String[], IFormatProvider, DateTimeStyles, DateTime)

Get a date in formart "dd/mm/yyyy"

Hi @neerajmca5,

dDate->DateTime variable
False ->Convert.ToString(DateTime.TryParse("30/31/2018",dDate))
True -> Convert.ToString(DateTime.TryParse("04/11/2018",dDate))

In If condition you can use like as
False ->DateTime.TryParse("30/31/2018",dDate)
True -> DateTime.TryParse("04/11/2018",dDate)