cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2245
Views
0
Helpful
5
Replies

UCCX with Time Zones using the sub_datetime script

rore
Level 1
Level 1

Hi all!

Im using Jonathan Schulenberg sub_datetime.aef script which is an awesome script for grabbing
Timezone,currentTime,currentTimeInt date and dayofweek information.


I have implemented a script at a customer site using this logic and it works great!
But i bumped into a weakness in my solution that i wonder íf somebody can help out with!
For instance if i compare if a queue shall be open or closed by doing an IF on the following logic

If (currentTimeInt >= 070000 && currentTimeInt <= 180000) Then
True -> Goto CSQ-Step
False -> Goto ClosedPrompt, that works ok
But if i want to compare

If (currentTimeInt >= 070000 && currentTimeInt <= 010000) and trying to do same logic it fails....

because in some cases my customer want to keep a queue open to 010000 AM due to extend their support open hours!

Anthony Holloway mentioned in a thread: https://supportforums.cisco.com/message/3113264#3113264

that it would nice to have an enhancement to the sub_datetime (Jon's script,) and if that could return the DATE in a variable of type DATE, and the TIME in a variable of type TIME. This way you could use standard method calls to compare against for business hours in different TIME ZONES.

My question is if somebody can explain/help out how to:

  • 1. Modify the sub_datetime.script to return a DATE and a TIME variable based on the input TIMEZONE variable.
  • 2. Use these returned DATE and TIME variables to compare with a Stored DATETIME variable from a DB read (SQL Database) within the UCCX script.

We will use this as a centrally placed UCCX and SQL DB that is spanning several Time zones and therefore need to compare different business hours in several Time zones.

Thx, Mikael

5 Replies 5

Gergely Szabo
VIP Alumni
VIP Alumni

Hi,

Jonathan Schulenberg's script already contains the timeZone parameter/variable, if set, it will be taken into account. If not, the default (local) time zone will be used.

Getting the actual date as Date and time as Time is easy, just do D[now] and T[now], respectively. However, I don't see the reason why anyone would want to get time as Time in a different timezone, since you need to get hours, minutes etc anyway.

What you might want to do is this:

{

// fragment to get the hour part of the actual time in Seattle - PST timezone as int:

java.util.Calendar localCal = new java.util.GregorianCalendar();

java.util.Calendar seattleCal = new java.util.GregorianCalendar(java.util.TimeZone.getTimeZone("PST"));

seattleCal.setTimeInMillis(localCal.getTimeInMillis());

return seattleCal.get(java.util.Calendar.HOUR_OF_DAY);

}

Of course, this must be assigned to an int variable.

About comparing SQL DATETIME values: how do you want to store it - do you need the date part or just the time part? What kind of database (SQL server, DB2, Oracle)? Could you please give us more details?

One more thing. You wrote:

If (currentTimeInt >= 070000 && currentTimeInt <= 010000) and trying to do same logic it fails....

Well, yes, since you are comparing int values, in other words, numbers, and a number cannot be greater than 70000 and less than 10000 ;-) But you can always modify your script. For instance, you might want to do this:

If (currentTimeInt >= 10000 && currentTimeInt <= 70000) then the script follows the off-hours logic, and if the condition yields false, the business hours logic.

G.

Hi Gergely

For the TIMEZONE and sub_datetime script

I had an idea that if it were possible to grab like  the "Time" information from my a specified TIMEZONE from Jon's script and store it in a Time variable in the UCCX editor and then compare that with a stored SQL 2008 Time parameter that stores that Timezone(office) business hours "start time" and "end time". My hope was to use some new logic in my script like further below:

Database:

SQL 2008

And time values are stored in Time-format

Hopefully be able to use something like below instead of: If (currentTimeInt >= 070000 && currentTimeInt <= 010000)

SetCal_T_Open =Time.valueOf(T_Open)

SetCal_T_Close =Time.valueOf(T_Close)

Cal_Now = T[NOW]

IF (Cal_Now .after( Cal_T_open ) && Cal_Now .before( Cal_T_Close )) Then

True

Goto open

False

Goto close

Do i get it right. Is there any better best practice? I'm not a programmer/sql guy!

Thx, Mikael

Hi,

if I were you, I'd just use plain integers (INT) in the database table. Or if you insist on using TIME type, then I'd just do cast before actually doing anything with it in UCCX. This would enable using Jonathan Schulenberg's script.

About that business hours problem: it'd still work, you just need to tweak it first, for instance, with a condition:

if (timeInt1 < timeInt2) {

  if (localTimeInt > timeInt1 && localTimeInt < timeInt2) {

   // open for business

  } else {

   // sorry, off business hours, come back later

} else {

  if (localTimeInt > timeInt1 || localTimeInt < timeInt2) {

   // open for business

   } else {

   // sorry, off business hours, come back later

}

}

Where timeInt1 is the "low" time value (start of the business hours) and timeInt2 is the "high" value (end of business hours).

I hope this hepls.

G.

Hi Gergely!

Very nice and clean! Thank you!

I did a variance of your thoughts by sending in the TIMEZONE to Jon's script and then GRABBING the CurrentDate and the Currenttime as the outpot and use these returned values in a uccx DB read by doing a SQL Select:

SELECT * from exceptions WHERE $currentDate >= eDateStart and $currentDate <= eDateEnd and $currentTimeSet >= eTimeStart and $currentTimeSet <= eTimeEnd

I seems to work great as long you don't pass 23:59:59 as the value for the end of business hours. By this i now compare Date and Time as STRING types and i don't need to do the IF checks in the UCCX script. Could this be a way to go? What do you think, Gergely!?

rgds, Mikael

Hi,

either way, what I had written earlier, uses Java code, what you have written, is SQL - it's almost the same, but at a different level. In order to get rid of the "past 23:59:59 problem", you'll have to modify your SQL table, to have the eDateEnd column contain the date when business hours end - and if it's past midnight, the date should be already next day, right?

G.