title: Trying to convert a 7 digit julian date into MMDDYY format
body: <p>I'm trying to convert a 7 digit julian/mainframe date into a calendar date of format mmddyy in SQL Server.
  An example of this being julian date <strong>2005020</strong>, where the first 4 digits are the year, 2005, and the last three are the day number in a calendar, so 020 = january 20. So I'd need to get this date as 012005(MMDDYY) in SQL Server.</p>
  <p>I've been using the following query but keep getting an error after it loads a few records:</p>
  <pre><code>SELECT DATEADD(day,CAST(RIGHT([julianDateColumn],3) as int)-,LEFT([julianDateColumn],4))
  </code></pre>
  <p>The error I've been getting:</p>
  <blockquote>
  <p>Conversion failed when converting date and/or time from character string.</p>
  </blockquote>
  <p>Originally I was doing this in an Access DB using the &quot;DATESERIAL&quot; function but from what I've seen the closest thing to that in SQL Server was &quot;DATEFROMPARTS&quot;, I tried using the following formula but it also didn't work:</p>
  <pre><code>DATEFROMPARTS([julianDateColumn]/1000,1,[julianDateColumn] % 1000)
  </code></pre>
  <p>Thanks in advance!</p>