convert d/m/yyyy to YYYY-MM-DD

My csv has data like this

x,x,3452,2/18/1986,abc
x,g,19711,1/24/1986,abc

i want to replace date in the following format YYYY-mm-dd

how do i convert using awk script ?

nawk -F, -v OFS=, '{split($4,a,"/");$4=sprintf("%s-%02d-%02d", a[3],a[1],a[2])}1' myFile.csv

Hello Vgersh,

i've been studying awk and gawk recently and so I'd like to find out if we can do this using gsub or gensub functions?

when i used

/usr/xpg4/bin/awk -F\, '{printf "%s\n", $4}' FILE   it gives
2/18/1986
1/24/1986

But i tried it with gsub and gensub but couldnt do it (there are 3 sub fields in 2/18/1986)

usr/xpg4/bin/awk -F\, '{print gensub(/(.+)\/(.+)\/(.+)/, "\\3/\\2/\\1", "g", $4)}' FILE

this part gave error,
please advice me.
thanks in advance

'gensub' is a gawk extension not available in most other awk-s.

sed 's~\([0-9]+\)/\([0-9]+\)/\([0-9]+\)~\3-\1-\2~' file

Edidataguy thanx, your code seemed ok to me but it didnt work, not gave an error and it does not update the file:

server1{root}>cat date.txt 
x,x,3452,2/18/1986,abc
x,g,19711,1/24/1986,abc
server1{root}>sed 's~\([0-9]+\)/\([0-9]+\)/\([0-9]+\)~\3-\1-\2~' date.txt
x,x,3452,2/18/1986,abc
x,g,19711,1/24/1986,abc

A bit modification as follows needed:

sed 's|.*,\([0-9]*\)/\([0-9]*\)/\([0-9]*\),.*|\3-\1-\2|' file_name.txt

Thanks Everyone.

Then change it as follows (escape the + also):

sed 's~\([0-9]\+\)/\([0-9]\+\)/\([0-9]\+\)~\3-\1-\2~' date.txt