There's nothing wrong with using
CDate
function, but i'd recommend to use newer technics to convert string to date/time value, because of several reasons. More you'll find here:
Type Conversion Functions (Visual Basic) | Microsoft Docs[
^]
Please, check this:
Parsing Date and Time Strings in the .NET Framework | Microsoft Docs[
^]
So,
DateTime.Parse
or
DateTime.ParseExact
is that what you're looking for.
In general: you have to use date instead of string data type to avoid several problems in a future. Note, that different
CultureInfo[
^], which may cause the date (stored in a string) to be not convertible.