BookmarkSubscribeRSS Feed
skidooman34
Calcite | Level 5

Hello,

I am needing some help in changing a datetime format back to a date format. For example, I have a value of   28OCT2013:21:26:58.819000

How can I create another variable and keep only the first 9 characters, in this case 28OCT2013 ? Can I do a simple SUBSTR command?

Help would be much appreciated!

3 REPLIES 3
ChrisHemedinger
Community Manager

You could use the DATEPART function.  Or, simply apply a DATE format and leave the original value as is!  See:

Do you mind if we dance with your DATEs (or DATETIMEs)? - The SAS Dummy

Chris

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
skidooman34
Calcite | Level 5

Thanks for the quick response.

I tried doing the simple date format, I used

28OCT2013:21:26:58.819000 (variable is called ofr_create_dt)  and if I simply put

date(ofr_creat_dt) as date1

I got back a result of 19701?

Any ideas?

AncaTilea
Pyrite | Level 9

...

you  then can format the date1 variable with date9. format and you get the date in a more readable format.

date(ofr_creat_dt) as date1

format date1 date9.;

Good luck!

Anca.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 880 views
  • 0 likes
  • 3 in conversation