How to edit date values in a data table?

Hi All,

I have a complicated question:

I have a data table dt_date where I am pulling customer name, account number and date of birth from a database. The DOB is in MM/DD/YYYY 00:00:00 format. I need to first convert the DOB from that format to YYYY-MM-DD format. Then, I need to try to compare the date values in that table with the date value stored in a string str_DOB. If there is a match, I need to replace the DOB value in another data table (dt_CustomerInfo) by finding the matching customer name in that customer info data table.

How do I do this?

Build Datatable For replacing the items
Use For each row in datatable:
For Each Row In dt_date
row(“DOB”).ToString = DateTime.ParseExact(row(“DOB”).ToString(), “MM/dd/yyyy HH:mm:ss”, CultureInfo.InvariantCulture).ToString(“yyyy-MM-dd”)
Take If Condition:
Add datarow

After for each use write range workbook

Hi @dla0313 ,
You can try
str1=“MM/dd/yyyy 00:00:00”
tempDate = Convert.ToDateTime(str1)

str_DOB = row(“date of birth”).toString()
if str_DOB.contais(string you want to compare)
→ assign