BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I am new to SAS and I am not familiar with how it handles dates.

When the difference of two dates is computed, what is the output in the form of? The default is integer, but I do not know what it represents.

For example:

12DEC2005:13:00:00 - 07DEC2005:00:00:00 = 478800

If I format the computed column to be date it gives me a non-sense value (at least non-sense to me).

Is there a conversion I should perform to get the value into days?

Thank you in advance for the help.
2 REPLIES 2
Doc_Duke
Rhodochrosite | Level 12
Dates are the number of days from 1/1/1960.
Date-Times are the number of seconds from midnight on 1/1/1960.

Date1-Date2 = number of days from date2 to date 1.
DateTime1-DateTime2 = number of seconds between the two.

There are at least two ways to get days from datetime1 and datetime2:

datepart(datetime1) - datepart(datetime2) yields the number of days (dropping off the times).

(datetime1-datetime2)/(60*60*24) yields days that have a decimal component.
deleted_user
Not applicable
Thank you Doc@Duke for the help

SAS Innovate 2025: Call for Content

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!

Submit your idea!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 2 replies
  • 709 views
  • 0 likes
  • 2 in conversation