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?
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?
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;
You can also do:
intnx('seconds', t1.flightdate,28800)
Tough command to remember everything....thanks all!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.