# String was not recognize as valid DateTime

**URL:** <https://forum.uipath.com/t/string-was-not-recognize-as-valid-datetime/321737>\
**Category:** Reboot Your Skills 2021\
**Tags:** week-4\
**Created:** [June 10, 2021, 10:17am UTC](https://forum.uipath.com/t/string-was-not-recognize-as-valid-datetime/321737 "2021-06-10T10:17:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alvin\_Apostol1](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/alvin_apostol1/32/220717_2.png) [@Alvin\_Apostol1](https://forum.uipath.com/u/Alvin_Apostol1)\
**Post date:** [June 10, 2021, 10:17am UTC](https://forum.uipath.com/t/string-was-not-recognize-as-valid-datetime/321737/1 "2021-06-10T10:17:38Z")

</div>

Hi Everyone,

I am having issues in converting string value to datetime variable using assign activity

I am getting the error below:

 ![image](https://global.discourse-cdn.com/uipath/original/3X/5/9/595d4e2365bcc73c3b344e6d1668ded1f509f405.png)

I already use the function below: but I still get the error message

 ![image](https://global.discourse-cdn.com/uipath/original/3X/1/0/10844e9ac98f17c672579946b882f3480f8310f0.png)

for my source file please see this:  
[TestFile.xlsx](https://forum.uipath.com/uploads/short-url/nMqHCJMhzbbhASC0plEOBinfkAs.xlsx) (10.2 KB)

I iterate on all those list using for each data table

Hopes someone can help me

Thank you!

---

<div class="post-metadata">

**Author:** ![Bogdan\_Eusebiu\_Siritanu](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/bogdan_eusebiu_siritanu/32/187515_2.png) [@Bogdan\_Eusebiu\_Siritanu](https://forum.uipath.com/u/Bogdan_Eusebiu_Siritanu)\
**Post date:** [June 10, 2021, 12:36pm UTC](https://forum.uipath.com/t/string-was-not-recognize-as-valid-datetime/321737/2 "2021-06-10T12:36:10Z")

</div>

Hi, when using DateTime.ParseExact, it does as the name suggests and looks for the exact format you gave, in your case “MM/dd/yyyy”. When read from the TestFile.xlsx the format actually includes the time too and it looks like this: “MM/dd/yy hh:mm:ss”.  
You need to use either: DateTime.ParseExact(dateTimeAsString, “MM/dd/yyyy hh:mm:ss”, System.Globalization.CultureInfo.InvariantCulture)  
or DateTime.Parse(dateTimeAsString).

---

<div class="post-metadata">

**Author:** ![Alvin\_Apostol1](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/alvin_apostol1/32/220717_2.png) [@Alvin\_Apostol1](https://forum.uipath.com/u/Alvin_Apostol1)\
**Post date:** [June 10, 2021, 4:02pm UTC](https://forum.uipath.com/t/string-was-not-recognize-as-valid-datetime/321737/3 "2021-06-10T16:02:37Z")

</div>

Thank you! It worked! @Bogdan_Eusebiu_Siritanu!

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/system/32/182466_2.png) [@system](https://forum.uipath.com/u/system)\
**Post date:** [June 13, 2021, 4:02pm UTC](https://forum.uipath.com/t/string-was-not-recognize-as-valid-datetime/321737/4 "2021-06-13T16:02:38Z")

</div>

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.
