DateTime column from datatable to DateTime variable

Hello,

I have a table with a DateTime column, and want to exstract the value into a DateTime variable, is this possible or is it better to store the data as String in the datatable and convert to datetime with “.ToString”?

Datatable DT with column “FOM” of type “DateTime”, with a for each row i try Assign dateTimeVariable = row.Item(“FOM”), but I get: “Cannot assign from type System(Object) to System (DateTime)”

.ToString doesn’t convert to datetime. It converts to string.

The issue here is you’re only referencing row.Item(“FOM”) which is an object, not a datetime. Convert that to datetime…

assign dateTimeVariable = CDate(row.Item(“FOM”))