Hi,
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.
Regards,
Neeraj Yadav
Hi,
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.
Regards,
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);
}
else
{
Console.WriteLine("Invalid"); // <-- Control flow goes here
Refer this
Regards,
Arivu
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:
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)
Regards,
Arivu
Hey Arivu,
How do i use the above logic for this usecaes:
09/06/2018
06/09/2018
Thanks
Joshi
Hi ,
Both the date format are same??
@Joshikumarav
below will give you a boolean value
Date.TryParseExact(strDate,“dd/MM/yyyy”,Nothing,Globalization.DateTimeStyles.None,Nothing).ToString
@akila93 No there is no format on the column. Apparently the excel comes from various sources and each of them contains different formats of date.
@AkshaySandhu - your code may return true for both my cases. But, I need to extract the date from 06/09/2018 and 09/06/2018. Is there any way?
@Joshikumarav
if you know the date format for given string then yes…
Date.ParseExact(Str,DateFormatOfString,Nothing)
Hi,
You can try the following Date.TryParseExact(stringVariable,“MM/dd/yyyy”,Nothing,Globalization.DateTimeStyles.None,Nothing).ToStringt
Please mark as solution if this is your solution, or else let us know if this doesn’t work.
Regards,
Pavan H
Hi @Dominic
Downloaded the .xaml and tried filling in “now().tostring” which is giving a string like “07/10/2019 08:35:53” but the parsed date is 01/01/0001
My goal is yto get a datetime as string that can be passed in a filename (ie. no \ or / ) - preferably in a format like “dd-mm-yyyy tt.mm” (seen this format work)
Perfect
I have a similar goal to be achieved. " Checking if the excel data is in MM/DD/YYYY format " Cann anyone help me with xaml file
Hi @veerishu
Check this
Convert.ToDateTime(row( “ColumnName at”).ToString(“DD/MM/YYYY”))
Thanks
Ashwin.S