I’ve 2 variables one variable is var1=dt.rows(0)(“Date”).tostring, where var1 is string var and var2=DateTimeParseExact(var1.ToString,“MM/dd/yyyy”,system.globalization.Cultureinfo.InvariantCulture.AddDays(5)) and var 2 is of type datetime
In the first var i’m storing all the dates and in the secoind var i want to add 5 days to the date , I’m getting this error near var2 i.e., string is not recignized as a valid datetime
@nisha91_2177
Welcome to the forum
check the brackets and correct
DateTime.ParseExact(var1.ToString,“MM/dd/yyyy”,system.globalization.Cultureinfo.InvariantCulture ).AddDays(5)
first convert to datetime then add the days
I’m new to this and have very less working experience
Can you let me know how do i convert my string var to dattime
you already have done it see the quote. Just one bracket was on the wrong position. see the bold mark
yes but i still get the same error
please share screenshot from the current part of implementation thanks. In case of we cannot read the relevant code statements copy it to the post as well. thanks
Lets inspect by following:
check the yellow marks for help
Set a breakpoint on the failling assign activity
Debug and get paused
type in following statement in the immediate panel and run it (Enter, Enter)
dt.rows(0)("Date").tostring
share the result from the immediate panel with us,. Now we can check what is used for the conversion as string.
maybe the value comes from excel after read range into the datatable.
But we do see that format is different as specified on ParseExact
now change to
DateTime.ParseExact(var1.ToString,"MM/dd/yyyy HH:mm:ss",system.globalization.Cultureinfo.InvariantCulture).AddDays(5)
not able to upload the xaml file
do one this protottype your statement similar within the immediate panel.
so debug end execute
DateTime.ParseExact(var1.ToString,"MM/dd/yyyy HH:mm:ss",system.globalization.Cultureinfo.InvariantCulture).AddDays(5)
Try
Cdate(var1.toString.trim()).AddDays(5)
Cdate(Final_Date).AddDays(5)
Final_Date
var1.toString
@nisha91_2177 - Please check this…
there is a small typo in @ppr code(period is missing…sry)…It is datetime.parseexact but it was given as datatimeparseexact…and I just added the missing period and it is working fine…
In the immediate panel…instead of final_Date use the filteredDt_rows(0)(“CurrentDate”).tostring in the datetime.parseexact
@prasath17
Thank you, I followed and reach the top of topic
It was tested with period within immediate Box, we can see. It looks to me that the value from Datatable first row first col is ok,
but somewhere on var1, Final_Date var a confusion is issued. On the log message we do see a suspicious Day Name
Hi @nisha91_2177 ,
In End Date please use below code.
DateTime.ParseExact(FilteredDT.Rows(0)("CurrentDate").ToString,"MM/dd/yyyy HH:mm:ss",system.globalization.CultureInfo.InvariantCulture).AddDays(5)
Final_Date → you have added the day name also thats why you are getting the error, i have corrected it pls use the below xaml file.
flow switch.xaml (16.6 KB)
Regards,
Arivu
Thanks everyone for the support!
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.