String into datetime


I’m passing a date in as a string “130319”, but I need to convert it to a datetime object, because I want to compare it to the current system date.

How can I convert this string into a datetime ?

I’ve tried DateTime.Parse and DateTime.ParseExact, both didn’t work.


hi @MattWW,

create a variable with “Date” data type.
assign the value like this,
dateVariable = Date.parseExact("130319","ddMMyy",Nothing)


1 Like

All good…

I just tried,

DateTime.ParseExact(“130319”, “ddMMyy”, System.Globalization.CultureInfo.InvariantCulture)

And it worked …


you should mark @ddrdushy1 answer as the solution after all he did give you an idea to explore … just a thought :smiley:

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