On OSX, Linux, and BSD you can use the man stat (OSX) command to get the modification time. Read it into a variable using $( ... ) and check if that's greater than 45.
I am managed to get the script with the help of my friend. It works.
#!/bin/sh
#This script checks if the <filename> esixts in the <fileloc> and also if the modification date is less than 45 days.
filename=filename.txt
fileloc="filepath"
cd $fileloc
if [ -f $filename ]; then
echo "File Exists"
filestr=`find . -name $filename -mtime +45 -print`
if [ "$filestr" = "" ]; then
echo "File is not older than 45 days"
else
echo "File is older than 45 days"
fi
else
echo "File does not exist"
fi
exit 0