bash is not the best shell for date calculation as its date-manipulation capabilities are very limited.
With zsh:
zmodload zsh/datetime d=03012012 strftime -rs d %m%d%Y%H ${d}12 strftime %m%d%Y $((d-86400)) With ksh93:
d=03012012 printf "%(%m%d%Y)T\n" "${d:4}${d:0:4} yesterday" With bash, you'd either have to do the calculation by hand or rely on perl or some GNU or FreeBSD extensions of the date utility.