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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1071 views
  • 0 likes
  • 2 in conversation