it reads a column in excel with the date in Brazil format even dd / mm / yyyy
then we have in the variable string 01/10/2019
I converted the variable using the DateTime.ParseExact so far so good
but when trying to use AddDay I can’t find any correct syntax to use it with the variable string
I tried to change to datetime, but when I call the flow and pass the argument
in_TransactionItem.Item (“Initial Data”). ToString it doesn’t work
what i need is to be able to add days to the start date variable so that can do something until you reach the end date with the string type variable or manage to pass the parameter in the workflow transforming the variable to datetime … can anyone help?
give a try on
DateTime.ParseExact(in_TransactionItem.Item (“Initial Data”).toString, “dd/MM/yyyy”, CultureInfo.InvariantCulture).AddDays(1).toString(YourPatternOfOutputChoice)
Kindly note mm= minutes, MM= month
I’m trying to understand it.
So you have a date in brazil string format. You want to convert that to DateTime and Want to Add days to it.
But as per the error message, I can see you are directly passing the string to the DateTime argument.
Please trying parsing before you pass.
That’s right, I have two date string variables and I need to add days on the start date to do something until I reach the end date, I tried to convert using DateTime.Parse, but no syntax I use allows me to use AddDays with the string type variable , I changed the variable to the DateTime type, but when I pass the argument also the option strict error, in neither case can I find the correct solution
As I can see your syntax when you used DateTime parse, you were also using toString at the end which again results in a string.
Try removing the .toString at the end and assign to in_dateFinal as u did. In the second argument of the date time parse please change format to dd/MM/yyyy as suggested by @ppr.
in_dateFinal should be of type datetime and then you can use add days function to it.
This should help. Thanks
good, I hadn’t noticed that about mm and MM
I’m sorry, but this between relatives what would be the pattern of exit, I didn’t understand well
The formula given by @ppr should work perfectly for you. You were on the right track, but you added .ToString after parsing it to a datetime (which means you had a string, converted to date, then right back to string). You need to use the .addDays() method while it is a datetime variable before converting it back to a string
Perfect, now it worked perfectly … can I use the same logic to remove the / (Barra) from the date? I pass the date to save the file and managed to change it to DateTime so I can’t use Replace, I’m trying to fit it in the same logic
Yep, you can decide your own format.
For more formats, go through below docs.
thank you very much. I will look at the document
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.