Request working days from calendar in CRM 2015
I have created a calendar (weekdays) for a resource (for example a tool). How can I get the list, or at least the ranges of business days, directly from the database?
All I have found so far are calendar and calendar views. The problem with CalendarRule is that the rule is written with a pattern like
"FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,TU,WE,TH,FR"
I can't seem to find a way to use this in a SQL query.
source to share
Assuming weekdays mon
are fri
and your table calendar
is linked to a table resources
by calendar.workingdays = resources.daysworked
, unless it explicitly adjusts to fit them.
SELECT EXTRACT(dow FROM timestamp (to_timestamp(c.workingdays), "YYYY-MM-DD")), r.facility
FROM Calendar c
LEFT JOIN Resources r ON c.workingdays = r.daysworked
WHERE EXTRACT(dow FROM timestamp (to_timestamp(c.workingdays, "YYYY-MM-DD"))
NOT IN (0,6)
source to share