BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Spintu
Quartz | Level 8

I have a date format like below example. If i want to convert in MMDDYY10. Using DATEPART function it is not working

 

date='March 29, 2019 5:00:00 AM GMT+01:00';

 

Do we have any alternate way to convert character date to date format?

1 ACCEPTED SOLUTION

Accepted Solutions
Jagadishkatam
Amethyst | Level 16

Please try the below code

 

data have;
date='March 29, 2019 5:00:00 AM GMT+01:00';
newdate=datepart(input(scan(date,1,'G'),anydtdtm.));
format newdate mmddyy10.;
run;
Thanks,
Jag

View solution in original post

4 REPLIES 4
JosvanderVelden
SAS Super FREQ
Just to verify. The date from your example is a character value and you want to transform it into a sas date (numeric)?
Spintu
Quartz | Level 8

Yes , you are right

Jagadishkatam
Amethyst | Level 16

Please try the below code

 

data have;
date='March 29, 2019 5:00:00 AM GMT+01:00';
newdate=datepart(input(scan(date,1,'G'),anydtdtm.));
format newdate mmddyy10.;
run;
Thanks,
Jag
Spintu
Quartz | Level 8

thank you for your quick response.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 749 views
  • 2 likes
  • 3 in conversation