Assign: String '' was not recognized as a valid DateTime

Hi, I want to get the timespan between 2 dates. The format of the date in excel sheet is like “Monday, June 10, 2024”. I received an error Assign: String ‘’ was not recognized as a valid DateTime. Can anyone help?

Try this:

date1 = DateTime.ParseExact(dateString1, “dddd, MMMM dd, yyyy”, System.Globalization.CultureInfo.InvariantCulture)
date2 = DateTime.ParseExact(dateString2, “dddd, MMMM dd, yyyy”, System.Globalization.CultureInfo.InvariantCulture)

HI,

It seems input string is empty from the error message. For now, can you try to check input string of DateTime.ParseExact method?
And add if activity or filter datatable activity to skip it if necessary.

Regards,

I’m retrieving a column of data and I’m not sure how to put that in DateTime.ParseExact(CurrentRow.Item(“Password Changed Date”).ToString(),“MM/dd/yyyy”, System.Globalization.CultureInfo.InvariantCulture) :smiling_face_with_tear:

Hi @SurreyWong

Use below syntax in If activity

(DateTime.ParseExact(CurrentRow("Password Changed Date").ToString, "dddd, MMMM d, yyyy", System.Globalization.CultureInfo.InvariantCulture) - DateTime.ParseExact(CurrentRow("Expired Date").ToString, "dddd, MMMM d, yyyy", System.Globalization.CultureInfo.InvariantCulture)).TotalDays<2

Regards,

Hi,

It’s still giving me the same error

If: String ‘’ was not recognized as a valid DateTime.

@SurreyWong

Can you show the excel data screen shot and also print it in Immmediate panel screen shots

Regards,

here you go 1/2

image

2/2

@SurreyWong

No need to use those 2 assign activities you can delete that and in Read Range activity enable Preserve Format option

Regards,

Thank you, I’ll mark this as solved :star_struck:

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