How to store value from a function and use it?

There is one function to calculate previous day value and then touch one file with that date.The problem is i am getting the previous day value but not able to store it in other variable and use it.

PREVIOUS_DATE_FUNCTION()
{

date '+%m %d %Y' | 
{ 
read MONTH DAY YEAR
DAY=`expr "$DAY" - 1` 
case "$DAY" in 
        0) 
           MONTH=`expr "$MONTH" - 1` 
                case "$MONTH" in 
                        0) 
                           MONTH=12 
                           YEAR=`expr "$YEAR" - 1` 
                        ;; 
                esac 
        DAY=`cal $MONTH $YEAR | grep . | fmt -1 | tail -1` 
esac 
    PREVIOUS_TEMP_DATE=$YEAR-$MONTH-$DAY
    echo "$PREVIOUS_TEMP_DATE"
}
}


PREVIOUSDATE="`(PREVIOUS_DATE_FUNCTION)`"
   tempfile=CANCEL_FILE_$PREVIOUSDATE

Output i am getting is tempfile=CANCEL_FILE_

And what does echo $PREVIOUSDATE give you?

+ PREVIOUSDATE=2012-06-26
+ echo 2012-06-26
2012-06-26

Do you have access to a database? You could get the date from there and put it into a shell variable. Example using Oracle:

$ cat x
#!/usr/bin/ksh

eval $(print "select 'YESTERDAY='||to_char(sysdate-1, 'YYYY-MM-DD') as YESTERDAY from dual;" | sqlplus -s / | grep YESTERDAY=)

print "yesterday: $YESTERDAY"

$ x
yesterday: 2012-06-26
$

no please tell me how to save the value in variable and use it, Thanks..!!

See if this works for your shell and system, whatever it is (you never told us):

$ PREVIOUSDATE=`TZ=XYZ+24 date '+%Y-%m-%d'`
$ echo $PREVIOUSDATE
2012-06-26
$

But when i am using this

PREVIOUSDATE="`(PREVIOUS_DATE_FUNCTION)`"    tempfile=CANCEL_FILE_$PREVIOUSDATE

I am not getting the output correct...i am only getting

tempfile=CANCEL_FILE_

but i want

tempfile=CANCEL_FILE_2012-06-26

It would seem that PREVIOUSDATE is ending up null, which means the function must be failing. I showed an alternate way to get yesterday's date without having to call a function.

$ PREVIOUSDATE=`TZ=XYZ+24 date '+%Y-%m-%d'`
$  echo $PREVIOUSDATE
2012-06-26
$ tempfile=CANCEL_FILE_$PREVIOUSDATE
$ echo $tempfile
CANCEL_FILE_2012-06-26
$