Difference between two datetime in hours,minutes and seconds in SAS is accomplished using INTCK() Function. Difference between two datetime in hours in SAS using INTCK() takes ‘hour’ as argument, Difference between two dates in minutes in SAS using INTCK() takes ‘minute’ as argument, Difference between two dates in seconds in SAS using INTCK() takes ‘second’ as argument. Let’s see an example of each
- Difference between two datetime in hours in SAS – calculate number of hours between two timestamp with an example
- Difference between two datetime in minutes in SAS – calculate minutes between two timestamp with an example
- Difference between two datetime in seconds in SAS – – calculate seconds between two timestamp with an example
Syntax INTCK in SAS:
- Interval – can be in minutes, seconds, hours,weeks, days, months,quarter and year
- Start_date and end_date are between two dates which we will be finding interval
So we will be using EMP_DET Table in our example
Difference between two datetime in hours in SAS:
Difference between two datetime in hours is accomplished using INTCK function with ‘hour’ as argument as shown below.
/* difference between two timestamp in hours */ data emp_det1; set emp_det; hours_since = intck('hour',lastlogin,curr_datetime); run;
So the resultant table will be
Difference between two datetime in minutes in SAS:
Difference between two datetime in minutes is accomplished using INTCK function with ‘minute’ as argument as shown below
/* difference between two timestamp in minute */ data emp_det1; set emp_det; minute_since = intck('minute',lastlogin,curr_datetime); run;
So the resultant table will be
Difference between two datetime in seconds in SAS:
Difference between two datetime in seconds is accomplished using INTCK function with ‘second’ as argument as shown below
/* difference between two timestamp in seconds */ data emp_det1; set emp_det; second_since = intck('second',lastlogin,curr_datetime); run;
So the resultant table will be