SELECT REC.FULL_NAME,

CASE LEN(REC.BIRTH_DATE)
WHEN 8 THEN convert(varchar(10), cast(REC.BIRTH_DATE  as datetime),21)
WHEN 6 THEN convert(varchar(10), SUBSTRING(REC.BIRTH_DATE,1,4)+'-'+SUBSTRING(REC.BIRTH_DATE,5,2),21)
WHEN 4 THEN convert(varchar(10), REC.BIRTH_DATE,21)
ELSE NULL
END AS 'Birth Date'

FROM RECORDS REC

Disclaimer: Blackbaud provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes you are familiar with Structured Query Language and the tools used to create and modify SQL statements and Crystal Reports. Blackbaud Customer Support may help explain the functionality of a particular procedure, but we will not modify, or assist you with modifying, these examples to provide additional functionality.