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

Hi all - What I am trying to accomplish is to convert a text date (Open Date) to a DateT  ime (Month End Date).

For example:

OpenDate = 2008-12-12

Below is the code I am using to create a OpenMonth Field

format MonthOpened DateTime22.3;
MonthOpened = dhms(input(OpenDate,yymmdd10.),0,0,0);

OpenMonth = 12DEC2008:00:00:00.000

I keep getting a conversion of the text date to date time instead of 31DEC2008:00:00:00.000

I know that I need to nest the intnx function but I can't seem where to correctly next the function.

intnx('month',MonthOpened,0,'end')

I know that I can do this in multiple steps, but I would like to create one nested function to do the conversion for me.

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
DBailey
Lapis Lazuli | Level 10

MonthOpened = dhms(intnx('month',input(OpenDate,yymmdd10.),0,'end'),0,0,0);

View solution in original post

1 REPLY 1
DBailey
Lapis Lazuli | Level 10

MonthOpened = dhms(intnx('month',input(OpenDate,yymmdd10.),0,'end'),0,0,0);

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!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 923 views
  • 0 likes
  • 2 in conversation