How to get date in format "MM/dd/yy"

Greeting everybody. I need to read a datatable that comes from a website and get the text from a specfic column. That cell contains the date in the format “MM/dd/yy” which I will compare to today’s date to get the time frame. The problem is that I’m receiving an error “String was not recognized as a valid DateTime”. How to assign a string in “MM/dd/yy” to a DateTime variable? Thanks.

  1. stringvariable = Split(CurrentRow.Item(“Column”).ToString," ")(0) → get the content from the cell
  2. datetimevariable = DateTime.ParseExact(stringvariable,“MM/dd/YY”,System.Globalization.CultureInfo.InvariantCulture) → convert to datetime → returning error, I have tried lots of combination for the date format

Hi @Mateus_Snk

Can we see how is your value in excel?

Also give a try with



hi @Mateus_Snk

Welcome To the Community!

The error is with your date format that you’ve written as the second parameter.
You need to correct that and it’ll work:

datetimevariable= DateTime.ParseExact(stringvariable,“MM/dd/yy”,System.Globalization.CultureInfo.InvariantCulture)

Assuming your date is something like “05/19/23” in the stringvariable.


Happy Automation!! :smiley:

Thank you. It worked


Check this helpful post for more information about DateTime.



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