Chapter Contents

Previous

Next
INTNX

INTNX



Advances a date, time, or datetime value by a given interval, and returns a date, time, or datetime value

Category: Date and Time


Syntax
Arguments
Examples
See Also

Syntax

INTNX('interval',start-from,increment<,'alignment'>)

Arguments

'interval'
specifies a character constant or variable. The argument interval can appear in upper- or lowercase.

The value of the character constant or variable must be one of those listed in this table:

Date Intervals Datetime Intervals Time Intervals
DAY DTDAY HOUR
WEEKDAY DTWEEKDAY MINUTE
WEEK DTWEEK SECOND
TENDAY DTTENDAY
SEMIMONTH DTSEMIMONTH
MONTH DTMONTH
QTR DTQTR
SEMIYEAR DTSEMIYEAR
YEAR DTYEAR

Requirement: The type of interval (date, datetime, or time) must match the type of value in start-from and increment.

start-from
specifies a SAS expression that represents a SAS date, time, or datetime value identifying a starting point.

increment
specifies a negative or positive integer that represents the specific number of time intervals.

'alignment'
specifies one of these values:

BEGINNING
specifies that the returned date is aligned to the beginning of the interval.
Alias: B

MIDDLE
specifies that the returned date is aligned to the midpoint of the interval.
Alias: M

END
specifies that the returned date is aligned to the end of the interval.
Alias: E

Default: BEGINNING


Examples

SAS Statements Results
yr=intnx('year','05feb94'd,3);
put yr / yr date7.;

 
13515 
01JAN97
x=intnx('month','05jan95'd,0);
put x / x date7.;
 
12784
01JAN95
next=intnx('semiyear','01jan97'd,1);
put next / next date7.;
 
13696
01JUL97
past=intnx('month2','01aug96'd,-1);
put past / past date7;

 
13270
01MAY96
sm=intnx('semimonth2.2',
'01apr97'd,4);
put sm / sm date7.;
 

13711 
6JUL97

These examples illustrate advancing a date using an alignment value:

SAS Statements Results
date1=intnx('month','01jan95'd,5,
      'beginning');
 put date1 / date1 date7.;
 

12935 
01JUN95
date2=intnx('month','01jan95'd,5,
      'middle');
put date2 / date2 date7.;
 

12949
5JUN95
date3=intnx('month','01jan95'd,5,
      'end');
put date3 / date3 date7.;
 

12964
30JUN95


See Also

Function:

INTCK


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.