Hi,
I am facing problem while executing a Datetime.ParseExact in the assign activity. But i when print it in message box using hardcoded value same syntax is working fine.
Input(Excel)
Assign:
row(“Datetime Parse(Out)”) = Datetime.ParseExact(row(“Out”).ToString,“HH:mm:ss”,system.globalization.cultureinfo.invariantculture).ToString(“h:mm tt”)
Message Box:
Datetime.ParseExact(“11:15:00”.ToString,“HH:mm:ss”,system.globalization.cultureinfo.invariantculture).ToString(“h:mm tt”)
Error:
DateTime ParseExact: String was not recognized as a valid DateTime
I have referred various posts and microsoft docs, still I am unable to figure what I am missing here…
Please assist.
Srini84
(Srinivas)
November 23, 2020, 6:14pm
2
1 Like
@Srini84 - I have already watch your video. What I am doing here is little different and my goal is to use Datatime.ParseExact…
Srini84
(Srinivas)
November 23, 2020, 6:21pm
4
@prasath17
Okay, you want to change the format of the time using DateTime.ParseExact rite?
Thanks
Yes…that is correct.
On the second video link, using DateDiff you can usely find out the difference between date or time…
Srini84
(Srinivas)
November 23, 2020, 6:41pm
6
@prasath17
Try this below
DateTime.ParseExact(row("Out").ToString,“MM/dd/yyyy HH:mm:ss”,System.Globalization.CultureInfo.InvariantCulture).Tostring("HH:mm tt")
Hope this helps you
Thanks
Thanks… @ksrinu070184
Nope…it didn’t work.i have already tried all the variations…But the same combination is working with Messsagebox…
There should be something to do with Excel…
ppr
(Peter Preuss)
November 23, 2020, 6:50pm
8
@prasath17
hava a look on this xaml:
FindNotMatchingDateFormatDates.xaml (6.8 KB)
After modifying it to your scenario it can be used for identifying the non parseable dates.
In combination with excel check following:
blank after dates, fix with trim
format in datatable different as visually in Excel - inspect while debugging and adopt the format
empty cells - check and handle as by your needs
2 Likes
Srini84
(Srinivas)
November 23, 2020, 6:57pm
9
@prasath17
Check the output and write back to the excel
Hope this is what you required, rite?
Workflow
Main.xaml (9.7 KB)
Date.xlsx (7.3 KB)
Hope this helps you
Thanks
1 Like
prasath17
(Guru)
November 23, 2020, 6:57pm
10
Thanks @ppr … Sure I will take look.
While debugging I found that cell value is different than “Actual cell value” - As shown below
Could this be a problem?
ppr
(Peter Preuss)
November 23, 2020, 7:02pm
11
just run the analyzer xaml and we have a clear list of all issue date strings
1 Like
prasath17
(Guru)
November 23, 2020, 7:03pm
12
@Srini84 - wow…this did it the trick…
My syntax was wrong, i was missing ‘MM/dd/yyyy’. Thank you so much…
1 Like
system
(system)
Closed
November 26, 2020, 7:03pm
13
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.