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

I'm trying to increment a date time that is formatted 19FEB2019:00:00:00.000, using the intnx function by 10 days, but

Using this code:

INTNX('dtday', t1.CLCL_RECD_DT,10)

is returning  1867017600

and i'm not entirely sure what to do with that, is that 10 days after in seconds? Can I convert it?

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

You can apply format=datetime20. to your result.

 

Yes it is 10 days after in seconds

 

you could use a datepart function if you want to extract date value from datetime value. Not sure what you want to do though

View solution in original post

4 REPLIES 4
novinosrin
Tourmaline | Level 20

You can apply format=datetime20. to your result.

 

Yes it is 10 days after in seconds

 

you could use a datepart function if you want to extract date value from datetime value. Not sure what you want to do though

Tom
Super User Tom
Super User

That is what you asked for.  Attach a datetime format, like DATETIME19.,  to the variable and it will be displayed in a more human readable way.

108   data _null_;
109   old='19FEB2019:00:00:00.000'dt;
110   new=intnx('dtday',old,10);
111   put old= old comma19. old datetime19.;
112   put new= new comma19. new datetime19.;
113   run;

old=1866153600       1,866,153,600 19FEB2019:00:00:00
new=1867017600       1,867,017,600 01MAR2019:00:00:00
Schmageggy
Fluorite | Level 6
both of these solutions are very helpful and I appreciate, really the first
one is all I needed to use in a between filter. thank you though will use
it for the output
Tom
Super User Tom
Super User

@Schmageggy wrote:
both of these solutions are very helpful and I appreciate, really the first
one is all I needed to use in a between filter. thank you though will use
it for the output

Right. There is no need to attach the format to use the value in code.  The formats just make the values easier for humans to read.

 

1867017600 and '01MAR2019:00:00:00'dt represent the same underlying numeric value.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 685 views
  • 3 likes
  • 3 in conversation