Desktop productivity for business analysts and programmers

Computing difference of two dates

Reply
N/A
Posts: 0

Computing difference of two dates

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.
Trusted Advisor
Posts: 2,114

Re: Computing difference of two dates

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.
N/A
Posts: 0

Re: Computing difference of two dates

Thank you Doc@Duke for the help
Ask a Question
Discussion stats
  • 2 replies
  • 101 views
  • 0 likes
  • 2 in conversation