Date format issues

I would like to get the below in YYYY MMDD format,

Last date of the week
Last date of the month
Last date of the year

And then compare d_date with the above if it matches it has to send some email.

 
        while read email_address; do
        mail -s "$subject" $email_address < $temp/$FileName
       done
 

How can I implement it, lets say d_date is 20140325

 
if ( d_date == Last date of the week )
then 
...
fi
 

For Last date of the week, you can rather get Day and compare. If you think sunday is the last day of the week

if[[ $(date +%a) == "Sun" ]]

For last day of he year, you can compare if month and data is 12, 31

if[[ $(date +%m%d) == "1231" ]]

I will check for last day of the month

date -d "1 day ago $(date +"%Y%m01" -d next-month)" "+%Y%m%d"