Need a string in '9-2-1832' format in a '1832-09-02' format.Must be able to fill a 'date' type field in mysql.   
How to convert a string into a date in a given format
bash;mysql;date
Assuming your original date is month-day-year (September 2, 1832), something like this might work:$ date -d $(sed s/-/\//g <<< '9-2-1832') +%Y-%m-%d1832-09-02ExplanationThe date command, even at the current 8.25 version, won't accept a date of the format you list ('9-2-1832', a month-day-year date string with hyphens as separators).$ date -d '9-2-1832' +%Y-%m-%ddate: invalid date 9-2-1832But date will accept a month-day-year date string with slashes as separators.$ date -d '9/2/1832' +%Y-%m-%d1832-09-02You can use sed to swap the hyphens for slashes like so.$ sed s/-/\//g <<< '9-2-1832'9/2/1832Then you can put the sed command in a subshell to put everything together.$ date -d $(sed s/-/\//g <<< '9-2-1832') +%Y-%m-%d1832-09-02