Converting Date information

when trying to take a date from an excel file no matter what the format in excel is will move to EP as
2020/01/01 06:00:00 /0600
I am trying to convert it to mm/dd/yyyy and not having much luck. Any help would be appreciated.

here is some code I am using;
//Converting DOB for Epic
put patient.age into ptdob
replace “-” with “/” in ptdob
log ptdob
put characters 1 to 4 of ptdob into year
put characters 5 to 6 of ptdob into month
put characters 7 to 8 of ptdob into day
put “& month & “/” & day & “/” & year &” into ptdob
log ptdob

Can you just chunk it down right when you bring it in? I was able to chunk the “2020/01/01 06:00:00 /0600” string down and then convert it using the standard methods.
set excellagevar to “2020/01/01 06:00:00 /0600”
set excellagevar to characters 1 through 10 of excellagevar
put excellagevar
put formattedTime("%Y/%m/%d") into patientagevar1
put patientagevar1
put formattedTime("%Y") into patientagevar2
put patientagevar2
put formattedTime("%m/%d/%Y") into patientagevar3
put patientagevar3

I would have done it like this, @Gregbert :

set excellagevar to “2020-01-01 06:00:00 -0600”
put AsTime(excellagevar) into excellagevar
put formattedTime(“MM/dd/yyyy”,excellagevar) into ptdob
log ptdob

But this also fixes your code (you were selecting the wrong characters):

put “2020-01-01 06:00:00 -0600” into patient.age
put patient.age into ptdob
replace “-” with “/” in ptdob
log ptdob
put characters 1 to 4 of ptdob into year
put characters 6 to 7 of ptdob into month
put characters 9 to 10 of ptdob into day
put month & “/” & day & “/” & year into ptdob
log ptdob

Got something that worked with help from Anne the EP guru.

This worked out great

//Converting DOB for Epic
put patient.age into ptdob
log formattedTime ("MM/dd/yyyy", ptdob)
typetext formattedTime ("MM/dd/yyyy", ptdob), tab
log ptdob