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.

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

Register now!

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
  • 1966 views
  • 1 like
  • 3 in conversation