Assign: String was not recognized as a valid DateTime error

Hello Community,

When I try to convert a date from excel, it pops up “Assign: String was not recognized as a valid DateTime” error, any one can help? Thanks.

Hi @li.yu

What is the format on excel, can you show us the excel file date format.



Check below for your reference

Use output datatable activity and messagebox to view the data how it appears, If it appears in date format then check below

If date is showing as number then check below

Hope this may help you


1 Like

the excel date format is Custom, m/d/yyyy hh:mm AM/PM

Make Sure check excel file once and check hh:mm:ss

Or Use this code once

VariableA = Convert.ToDateTime(Your_String)

VariableA Type is System.DateTime

Chethan P

Hi @li.yu
try this way

DateTime.ParseExact(changeday,“MM/dd/yyyy hh:mm:ss tt”,System.Globalization.CultureInfo.InvariantCulture)

Thanks for sharing Srinivas!

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