Function to check if datetime is in work time

A couple of posts recently in the Yahoo MagicSolutions forum made me realise that there was no easy way of checking if a given datetime was during or outside working hours (as defined by the work schedule). Consequently I set about writing a UDF that would accept a work schedule name and datetime as an input and return 1 if the time fell within the given work schedule and 0 if it did not.

Because of the way things get formatted using WordPress I have saved the function as a text document available here: IsWorkTime Function

Depending on where you want to use UDF’s in Service Desk Express you need certain permissions to do so. Personally, whenever I create a function like this (assuming it is not returning any privaleged information) I grant execute permissions to everyone. To do this simply run the following SQL:

GRANT EXECUTE ON [_SMDBA_].[IsWorkTime] TO Public

In my next post I’ll discuss how to use UDF’s in business rules…

One thought on “Function to check if datetime is in work time

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s