Sunday, September 20, 2009

Obtain yesterday's date using perl

On shell scripting,
YDATE=`date '+%y:%m:%d' | awk -F":" '{printf"20%2d%2d%2d\n",$1,$2,($3-1)}' | sed 's/ /0/g'`

On perl scripting,
YDATE=`$(perl -e '@y=localtime(time()-86400);printf "%04d%02d%02d",$y[5]+1900,$y[4]+1,$y[3];')`

On oracle cmd,
to_char(sysdate-1,'DDMMYY')

No comments: