Hello All,
I am trying to calculate the time difference in hours by excluding weekends.
By using the code below to get the difference in hours:
LSC_Time_Diff = intck('hours','Status Time Date'n, 'Current time'n); ------> This gives me the difference in hours but done not exclude weekends.
I know that intck ('Weekday', field1, field2) will exclude weekends however I want to consider the timestamp and see the result in hours.
PS: I do not want business hours. I just want to exclude weekend hours (Sat & Sun = 48 hrs) to be excluded every time i run my code
Please advise and let me know if more information is needed.
Thank you.
@phoenix31 wrote:
Hello All,
I am trying to calculate the time difference in hours by excluding weekends.
By using the code below to get the difference in hours:
LSC_Time_Diff = intck('hours','Status Time Date'n, 'Current time'n); ------> This gives me the difference in hours but done not exclude weekends.
I know that intck ('Weekday', field1, field2) will exclude weekends however I want to consider the timestamp and see the result in hours.
PS: I do not want business hours. I just want to exclude weekend hours (Sat & Sun = 48 hrs) to be excluded every time i run my code
Please advise and let me know if more information is needed.
Thank you.
If you have a fixed known amount, such as 48 hours then subtract that. I suspect you would want a check that the interval actually crossed a weekend though if you are dealing with irregular intervals.
Subtract
intck('dtweek','Status Time Date'n, 'Current time'n) * 48
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.