BookmarkSubscribeRSS Feed
Calcite | Level 5

I have one datetime variable and I would like to add 7 days to the existing date/time


112/4/2019  15:21 PM12/5/2019  15:21 PM
212/5/19 12:42 PM12/12/19 12:42 PM


I did the following and didn't work

new_start_date = intck ('dtday', raw_start_date_time, 7)


I also tried intck('day'), intnx ('day'), and raw_start_date_time * 7 * 24 * 60 * 60.


No luck

Super User

INTNX, not INTCK() and dtDAY since you have a datetime.

new_start_date = intnx('dtday', raw_start_date_time, 7);

If you wanted to do it manually you need to ADD that date amount, not multiply it.


 raw_start_date_time  +  7 * 24 * 60 * 60
Super User Tom
Super User

INTCK() counts intervals.  You want INTNX().

Also are variables really datetime and not string?  I don't think SAS has a format to display datetime values in that style you are showing.  But perhaps that is data you typed into Excel instead?

Rhodochrosite | Level 12
New = raw+ 7 *24*3600 ;
A SAS datetime value is an integer number of seconds.
There are 3600 seconds in each of the 24 hours in a day


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
  • 4 in conversation