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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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