BookmarkSubscribeRSS Feed
BCNAV
Quartz | Level 8

I always get lost with INTNX

 

I have a date time variable called flightdate...example: 01JAN2014:00:28:00.000

 

I want to add 8 hours to this.  So I use intnx('hour', t1.flightdate,8) and I get 01JAN2014:08:00:00.000

 

I would like the minutes to come over as well and be 01JAN2014:08:28:00.000

 

Any way to get this to happen? 

3 REPLIES 3
Reeza
Super User

Make sure to specify the fourth parameter, the alignment or the default applies which is not what you want here. Instead try the 'S' option.

 

 intnx('hour', t1.flightdate,8, 's')

@BCNAV wrote:

I always get lost with INTNX

 

I have a date time variable called flightdate...example: 01JAN2014:00:28:00.000

 

I want to add 8 hours to this.  So I use intnx('hour', t1.flightdate,8) and I get 01JAN2014:08:00:00.000

 

I would like the minutes to come over as well and be 01JAN2014:08:28:00.000

 

Any way to get this to happen? 


 

PGStats
Opal | Level 21

You don't really need INTNX to do add or substract time to a datetime variable. You can respect SAS date and time conventions with time literals, like this:

 

nextFlightDate = flightDate + '08:00:00't;

PG
BCNAV
Quartz | Level 8

You can also do:

 

intnx('seconds', t1.flightdate,28800)

 

 

Tough command to remember everything....thanks all!

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1286 views
  • 2 likes
  • 3 in conversation