Time difference

Hi All,
I know there has been a lot of things that have been written about date arithmetic, but perhaps I have missed something..
The following script takes the input from a file name fail.txt with the following format:

CLASSDB 20060328122808
CPPARMS 20060814222056

Where $1 is a file name and $2 is the creation timestamp.

I have attempted to calculate the age of the file from reading the timestamp($2)

heres the script i wrote

#!/usr/bin/ksh
cat fail.txt | while read line
do
created=`echo $line | awk '{print $2}' | sed "s/\(.\{4\}\)\(..\)\(..\)\(..\)\(..\)\(..\)/\1\2\3/"` && name=`echo $line | awk '{print
 $1}'`
today=`TZ=aaa date +%Y%m%d`
days_old=`echo $(($today - $created))`
echo "$name       $created      $days_old" >> test_fail.txt
done
if [ -e test_fail.txt ]
then
uuencode test_fail.txt test_fail.rtf | mailx -s "test" g2kaushi@hewitt.com
rm test_fail.txt
fi

I get the error ":more tokens expected at the row where 'days_old" is being calculated(which is a minor issue).
The issue that i am more concerened with is
the "days_old" variable calculation is failing if the file is from the previous month or year.
I work on Solaris 8 so a lot of date options or the GNU date are not available to me.

I am only looking for a way to convert the timestamp of the fail.txt($2) to no of days from today.

I apologize if this has been discussed earlier but I was not able to find any age related threads.

Thanks in advance.

Are you actually trying to set TZ to 'aaa' or is this a typo?

In the following code snippet you are trying to subtract one datestring from another

days_old=`echo $(($today - $created))`

e.g. 20080721 - 20060328. This is not how you calculate date differences. Have a look in the FAQs on this site for "Date Arithmetic" for further information on how to actually calculate the difference between two dates.

Hi fpmurphy,
The statement today=`TZ=aaa date +%Y%m%d` is derived from a staement that i took from this forum which helped me to calculate the date two days ago.
the aaa is a typo..Thanks for pointing out......
I have already looked up the Date Arethmetic sectiobut will lokk closer this time and get back..Thanks for your response.
Thanks

Ok...I think I have another approach..

I need to convert the timestamp "20060328122808" in epoch time.
Then get the current epoch time of the system using

/usr/bin/truss /usr/bin/date 2>&1 | /usr/bin/awk '/^time/ {print $NF}

then subtract both the numbers to get the difference in epoch.

Then I should be able to convert the epoch time difference no of days..
does this sound possible.
All i need to know is how to convert the "20060328122808" to epoch time
and the how the convert the resultant epoch timestamp in no of days....
does this sound possible..??