IF (DATEPART('hour', [Action Start]) * 60) + DATEPART('minute', [Action Start]) > (60 * (12 + [Day Close Hour]) ) + INT([Day Close Minute])
THEN
// created after End of Day so round to start of next business day
DATEADD('minute', (60 * (24 + [Day Open Hour])) + INT([Day Open Minute]), DATETRUNC('day',[Action Start]))
ELSEIF
(DATEPART('hour', [Action Start]) * 60) + DATEPART('minute', [Action Start]) < (60 * [Day Open Hour]) + INT([Day Open Minute])
THEN
// created before Start of Day so round to start of business day
DATEADD('minute', (60 * [Day Open Hour]) + INT([Day Open Minute]), DATETRUNC('day',[Action Start]))
ELSE
[Action Start]
END
IF DATENAME('weekday',[Action Start : Rounded]) = "Saturday"
THEN
// move to start of day monday by adding two days (48 hrs) and the monday morning hours
DATEADD('minute', (60 * (48 + [Day Open Hour])) + INT([Day Open Minute]), DATETRUNC('day', [Action Start : Rounded]))
ELSEIF DATENAME('weekday',[Action Start : Rounded]) = "Sunday"
THEN
// move to start of day monday by adding a day (24 hrs) and the monday morning hours
DATEADD('minute', (60 * (24 + [Day Open Hour])) + INT([Day Open Minute]), DATETRUNC('day', [Action Start : Rounded]))
ELSE
[Action Start : Rounded]
END
DATEDIFF( 'minute',
[Action Start: Round to Weekdays],
DATEADD('minute', (60 * (12 + [Day Close Hour])) + INT([Day Close Minute]), DATETRUNC('day',[Action Start: Round to Weekdays]))
)
DATEDIFF('day', [Action Start: Round to Weekdays], [Action End : Round to Weekdays]) "DateDiff Minutes" DATEDIFF('minute', [Action Start: Round to Weekdays], [Action End : Round to Weekdays]) "DateDiff Weeks" DATEDIFF('week', [Action Start: Round to Weekdays], [Action End : Round to Weekdays])
(60 * (12 + [Day Close Hour (pm)] - [Day Open Hour (am)]) + INT([Day Close Minute (pm)]) - INT([Day Open Minute (am)]))
IF DATETRUNC('day', [Action Start: Round to Weekdays]) = DATETRUNC('day', [Action End : Round to Weekdays])
THEN
// the same day so just return the minutes between the two times on the same day
[DateDiff minutes]
ELSEIF DATETRUNC('week', [Action Start: Round to Weekdays]) = DATETRUNC('week', [Action End : Round to Weekdays])
THEN
// the two days are in the same week, so add the time on the created day, the time on the end day, plus a full day for each day between
(([DateDiff days] - 1) * [Minutes per workday] ) + [Start: Time to end of day] + [End : Time from start of day ]
ELSE
// the days are in two different weeks, so get the same calc as above, and subtract the weekends between
// weekends between would be datediff weeks * 2 * work minutes per day
(([DateDiff days] - 1 - ([DateDiff weeks] * 2)) * [Minutes per workday] ) + [Start: Time to end of day] + [End: Time from start of day ]
END
001456485
176 KB

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.