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
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.