SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

DATETIME20. to MMDDYY10.

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 13
Accepted Solution

DATETIME20. to MMDDYY10.

Hi,

 

This is a really simple problem, but I can't seem to find a solution.

 

My date variable is in an informat and format of DATETIME20. I want it to be in a MMDDYY10. format. How do I change my date variable from a DATETIME20. to MMDDYY10. format? I want my date variable that looks like this "01FEB2016:00:00:00" to look like this "02/01/2016."

 

 


Accepted Solutions
Solution
‎03-07-2017 11:08 AM
Super User
Super User
Posts: 7,950

Re: DATETIME20. to MMDDYY10.

Posted in reply to amanda_cr

Hi,

 

You want the datepart() function:

data want;
  thedt="01FEB2016:00:00:00"dt;
  thedt=datepart(thedt);
  format thedt mmddyy10.;
run;

View solution in original post


All Replies
Solution
‎03-07-2017 11:08 AM
Super User
Super User
Posts: 7,950

Re: DATETIME20. to MMDDYY10.

Posted in reply to amanda_cr

Hi,

 

You want the datepart() function:

data want;
  thedt="01FEB2016:00:00:00"dt;
  thedt=datepart(thedt);
  format thedt mmddyy10.;
run;
Occasional Contributor
Posts: 13

Re: DATETIME20. to MMDDYY10.

[ Edited ]

Awesome. That works perfectly!

 

Thank you, RW9.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 220 views
  • 0 likes
  • 2 in conversation