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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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