Dear Friends,
We have date in output as MM/DD/YYYY format and I want to convert it in DD/MM/YYYY format.
e.g.
12/31/2010 to 31/12/2010
We have checked forum for the solution but we are not getting matching query.
Please guide us
Thanks
Anushree.
Dear Friends,
We have date in output as MM/DD/YYYY format and I want to convert it in DD/MM/YYYY format.
e.g.
12/31/2010 to 31/12/2010
We have checked forum for the solution but we are not getting matching query.
Please guide us
Thanks
Anushree.
kent$ echo "12/31/2010" | awk -F'/' '{print $2 FS $1 FS $3}'
31/12/2010
kent$ echo "12/31/2010" | sed -r 's#([0-9]{2})/([0-9]{2})#\2/\1#'
31/12/2010
It worked.
Thanks for a clean and easy to understand solution
Thanks a lot.
If you have the control on the script that generates this output, you should change directly the way the output is generated ( date '+%d/%m/%Y' ) instead of performing an additionnal conversion step.
(format it the right way directly instead of formatting it the wrong way + converting it to a right format)
GNU date
date -d"12/31/2010" '+%d/%m/%Y'
Dear Pravin,
We are now able to generate out put as desired. But we want output with "-" separator.
i.e.
31/12/2010
to
31-12-2010
Can we do it?
Thanks
Anu.
date -d"12/31/2010" '+%d-%m-%Y'
OR
echo "12/31/2010" | awk -F'/' '{print $2 OFS $1 OFS $3}' OFS="-"