[Tex/LaTex] Date placement in letter class

letters

I'm using the letter template from the wiki. Here's the code:

\documentclass{letter}
\usepackage{hyperref}
\signature{Joe Bloggs}
\address{21 Bridge Street \\ Smallville \\ Dunwich DU3 4WE}
\begin{document}

\begin{letter}{Director \\ Doe \& Co \\ 35 Anthony Road
\\ Newport \\ Ipswich IP3 5RT}
\date{March 27, 2016}
\opening{Dear Sir or Madam:}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed tellus lacus,
suscipit ac condimentum eget, commodo in metus. Praesent malesuada placerat 
tortor ac convallis. Nam ultrices est metus, et pellentesque augue porta 
non. Nulla risus diam, congue non massa in, fermentum commodo lectus. Aenean
quis aliquam velit

\closing{Yours Faithfully,}

\end{letter}
\end{document}

All I want to do is keep the date on the right hand side, but move it down below the second address block. This is my first post on StackExchange so I'm sorry for the lack of an image.

Best Answer

You can use the \patchcmd command from the etoolbox package to patch the \opening command:

\documentclass{letter}
\usepackage{hyperref}
\usepackage{etoolbox}

\makeatletter
% If pagestyle is firstpage, remove old placement of date
\patchcmd\opening{{\raggedleft\@date\par}}{}{}{}
% If pagestyle is empty, remove vertical space after addess
\patchcmd\opening{\fromaddress \\*[2\parskip]}{\fromaddress}{}{}
% If pagestyle is empty, remove old placement of date
\patchcmd\opening{\@date \end{tabular}\par}{\end{tabular}\par}{}{}
% Insert new placement of date
\patchcmd\opening{{\raggedright \toname \\ \toaddress \par}}{{\raggedright \toname \\ \toaddress \par}{\raggedleft\@date\par}}{}{}
\makeatother

\signature{Joe Bloggs}
\address{21 Bridge Street \\ Smallville \\ Dunwich DU3 4WE}

\begin{document}

\begin{letter}{Director \\ Doe \& Co \\ 35 Anthony Road
\\ Newport \\ Ipswich IP3 5RT}
\date{March 27, 2016}
\opening{Dear Sir or Madam:}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed tellus lacus,
suscipit ac condimentum eget, commodo in metus. Praesent malesuada placerat 
tortor ac convallis. Nam ultrices est metus, et pellentesque augue porta 
non. Nulla risus diam, congue non massa in, fermentum commodo lectus. Aenean
quis aliquam velit

\closing{Yours Faithfully,}

\end{letter}
\end{document}

or you can patch it manually by including the following in your preamble:

\makeatletter
\renewcommand*{\opening}[1]{\ifx\@empty\fromaddress
  \thispagestyle{firstpage}%
    %{\raggedleft\@date\par}%       <--- REMOVED
  \else  % home address
    \thispagestyle{empty}%
    {\raggedleft\begin{tabular}{l@{}}\ignorespaces
      %\fromaddress \\*[2\parskip]% <--- REMOVED
      %\@date \end{tabular}\par}%   <--- REMOVED
      \fromaddress%                 <--- ADDED
      \end{tabular}\par}%           <--- ADDED
  \fi
  \vspace{2\parskip}%
  {\raggedright \toname \\ \toaddress \par}%
  {\raggedleft\@date\par}%          <--- ADDED
  \vspace{2\parskip}%
  #1\par\nobreak}
\makeatother

Both yield the same output:

Output with date below to-address