title: Format datetime day with st, nd, rd, th
body: <p>I'm creating a report in SSRS and across the top I have a header with a placeholder for "Last Refreshed" which will show when the report last ran.</p>
  
  <p>My function in the placeholder is simply this:</p>
  
  <pre><code>=Format(Now, "dddd dd MMMM yyyy hh:mm tt")
  </code></pre>
  
  <p>Which looks like this:</p>
  
  <blockquote>
    <p>Monday 22 September 2015 09:46 AM</p>
  </blockquote>
  
  <p>I want to format the day value with the English suffix of st, nd, rd and th appropriately.</p>
  
  <p>I can't find a built in function for this and the guides I've looked at so far seem to describe doing it on the SQL side with stored procedures which I don't want. <strong>I'm looking for a report side solution</strong>.</p>
  
  <p>I thought I could get away with an ugly nested <code>IIF</code> that did it but it errors out despite not giving me any syntax errors (whitespace is just for readability).</p>
  
  <pre><code>=Format(Now, "dddd " + 
  
  IIF(DAY(Now) = "1", "1st", 
  IIF(DAY(Now) = "21","21st",
  IIF(DAY(Now) = "31","31st",
  IIF(DAY(Now) = "2","2nd",
  IIF(DAY(Now) = "22","22nd",
  IIF(DAY(Now) = "3","3rd",
  IIF(DAY(Now) = "23","23rd",
  DAY(Now) + "th"))))))) 
  
  + " MMMM yyyy hh:mm tt")
  </code></pre>
  
  <p>In any other language I would have nailed this ages ago, but SSRS is new to me and so I'm not sure about how to do even simple string manipulation. Frustrating!</p>
  
  <p>Thanks for any help or pointers you can give me.</p>
  
  <p><strong>Edit:</strong> I've read about inserting VB code into the report which would solve my problem, but I must be going nuts because I can't see where to add it. The guides say to go into the <strong>Properties > Code</strong> section but I can't see that.</p>