BookmarkSubscribeRSS Feed
phoenix31
Fluorite | Level 6

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.

2 REPLIES 2
ballardw
Super User

@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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 2159 views
  • 1 like
  • 3 in conversation