Hi,
Is there any way we could change the date format listed below...
date I get is 03302007 (MMDDYYYY)
I need to change it to 20070330 (YYYYMMDD)
Thanks.
Hi,
Is there any way we could change the date format listed below...
date I get is 03302007 (MMDDYYYY)
I need to change it to 20070330 (YYYYMMDD)
Thanks.
echo '03302007' | sed 's#\(..\)\(..\)\(....\)#\3\1\2#'
If you are wanting the current system date in that format...
date +"%Y%M%d"
will produce...
20070903
Separate the components, then put them back together in the order you want:
date=03302007
temp=${date#??}
month=${date%"$temp"}
day=${temp%????}
year=${temp#??}
newdate=$year$month$day