How to convert string data into DateTime Variable

Hello,

I am trying to convert the string datatype into dateTime. but getting error. can anyone please help me to fix this.

Reading Excel value into string.(Here I stored the value in string because some time value will be null there at that time it gives error as DateTime cannot be null)

image

I am converting string into dateTime

image
image

getting below error.

image

Hi @nilesh.mahajan

Try as below

Split the string to insert the “/”, after that you can use Convert.DateTime(str).ToString(“MM/dd/yyyy”)

Mark as solution if this helps

Thanks

1 Like

Hey @nilesh.mahajan

  1. You can use if activity first to check if that value is null.
    String.IsNullOrEmpty(Rev_RefDT)

  2. use this
    DateTime.ParseExact(iString, “ddMMyyyy”, System.Globalization.CultureInfo.InvariantCulture)

:slight_smile:

Thanks
Arif Elahi

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