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!

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!

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.

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