## First Work Day after the mid point between two dates

Solved
Occasional Contributor
Posts: 10

# First Work Day after the mid point between two dates

All.

I'm very new to SAS and have a taks to calculate a field that:

Finds the mid point between two date fields. They are 'from' and 'to' date fields so am pretty confident the 'to' field will always be later than the 'from' field.

If the resulting day is a non working day (ie saturday or sunday), then provide the next working day (ie mon, tue, wed, thurs, fri). else provide the exact midpoint day.

Hope this makes sense!! NB they are DATE fields not DATETIME fields.

Accepted Solutions
Solution
‎01-09-2013 06:17 AM
Super Contributor
Posts: 644

## Re: First Work Day after the mid point between two dates

Posted in reply to ChrisElias

You can find the midpoint as the mean between the two dates (so order does not matter anyway).  I would suggest using the ceil function to round up to the next day in the case of a fractional result.  Then use the Weekday() function to detect day of week:  if the result is 1 (Sunday) add a dy, else if it is 7 (Saturday) add 2 days.

Richard

All Replies
Solution
‎01-09-2013 06:17 AM
Super Contributor
Posts: 644

## Re: First Work Day after the mid point between two dates

Posted in reply to ChrisElias

You can find the midpoint as the mean between the two dates (so order does not matter anyway).  I would suggest using the ceil function to round up to the next day in the case of a fractional result.  Then use the Weekday() function to detect day of week:  if the result is 1 (Sunday) add a dy, else if it is 7 (Saturday) add 2 days.

Richard

Occasional Contributor
Posts: 10

## Re: First Work Day after the mid point between two dates

Posted in reply to RichardinOz

Worked brilliantly - Thanks very much!

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
• 2 replies
• 453 views
• 1 like
• 2 in conversation