Converting a date time date to ddmmyyyyformat

I am reading a table using PROC SQL from a SQL Server database.  The DOB field is coming in datetime format.  

I would like to convert 02FEB1951:00:00:00.000    to     02FEB1951
moriniaAdvanced Analytics AnalystAsked:
Who is Participating?
 
Aloysius LowConnect With a Mentor Commented:
if you are looking to execute the code within sas:
PROC SQL;
create table .....
:
:
(DATEPART(DOB)) as DOB_DATE format DATE9.,
:
:
from ......
quit;
0
 
MSSystemsCommented:
declare @date datetime
set @date = '02FEB1951'

select @date as [Original Date]
, convert(varchar(10), @date, 106) as [dd mon yy]
, replace(convert(varchar(10), @date, 6), ' ', '') as [Requested format]
0
 
TempDBACommented:
You can use the following in your code

SELECT REPLACE(CONVERT(VARCHAR(11), <fieldName>,106), ' ', '') AS [DDMonYYYY]
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.