For example i have date in excel as 10-05-2023 from this to 05-10-2023
Give a try with the following
DateTime.ParseExact(strInput, "dd-MM-yyyy", System.Globalization.CultureInfo.InvariantCulture).ToString("MM-dd-yyyy")
Remember to replace the strInput variable for your currentRow variable
Regards
hi @sathish_Kumar6 ,
Can you provide the date that you’re getting in the sts variable in assign activity, Did you give the correct format there?
Or can you screenshot the date that you’re getting from Excel file?
The expression to convert data is written below and that should work if your input date format is coming as dd-MM-yyyy
DateTime.ParseExact(sts, “dd-MM-yyyy”, System.Globalization.CultureInfo.InvariantCulture).ToString(“MM-dd-yyyy”)
Thanks,
Aditya
Can I see the value you are retrieving in that variable please? I want to check the format
Regards
I have tried the given format but its not working so Iam Passing the variable as string so Is there any issue
Hi @sathish_Kumar6 : can you share your source file from where you’re reading the date column?
Sample.xlsx (10.0 KB)
Please check that sample file
Use this Expression for changing Date Time Format.
DateTime.ParseExact(DateTime_Variable, “dd-mm-yyyy”, System.Globalization.CultureInfo.InvariantCulture).ToString(“MM-dd-yyyy”)
Regards
Try to use this one
datetime.Parse(CurrentRow(3).ToString).Tostring(“dd-MM-yy”)
or
DateTime.ParseExact(CurrentRow(3).ToString,“MM/dd/yyyy”,system.Globalization.CultureInfo.InvariantCulture).ToString(“dd-MM-yyyy”)
Hi @sathish_Kumar6 ,
for me the date is visible in this format from your sample file: i.e. dd/MM/yyyy
So the expression for this would be:
DateTime.ParseExact(DateTime_Variable, “dd/MM/yyyy”, System.Globalization.CultureInfo.InvariantCulture).ToString(“MM-dd-yyyy”)
Hi @sathish_Kumar6 ,
Could you check the below Post, it does address the same issue, you could just use the format that is required for your case :
You do this in Excel by editing the cell’s formatting. It’s important to understand that datetimes don’t have a format. You format them when you view/output them. That’s what Excel is doing. It’s storing a datetime value and displaying it in a certain format - which you can change by right-clicking the cell (or column, or row, etc)
Just enable the preservet formar property in your read range activity, with this we will ensure that we are retrieving the same format we are watching in excel, then use the code i’ve shared
DateTime.ParseExact(strInput, "dd-MM-yyyy", System.Globalization.CultureInfo.InvariantCulture).ToString("MM-dd-yyyy")
Regards!
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.