cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
4850
Views
0
Helpful
10
Replies

UCCE Date and Time Function

jcvanwyng
Level 1
Level 1

I'm looking for good documentation on the Data and Time Functions in ICM scripts The Scripting and Media Routing Guide lacks good examples and is missing information. The information using the built-in help feature of the ICM Script Editor is actually more complete. However, they are almost word for word the same. What I want to do is collect digits to add to the current date and/or time to set a global variable to manually open or close a contact center group. For example, some groups may close periodically for a meeting and post a message say when they would be back. Currently, the way I have it set up, they call a number to manually open or close that group. But they must remember to open it again when they are done. I would like to prompt them to enter the number of hours to be closed, then add it to the current time and store that in a global variable. Then I can check that variable against the current time with an administration script to know when to open them up again automatically. My problem is finding comprehensive documentation on these built-in functions. Very frustrating.

Thanks.

Joel

10 Replies 10

Gergely Szabo
VIP Alumni
VIP Alumni

Hi,

I would probably do that with the IVR - both CVP and IP IVR have a rich tool set for date and time manipulation. What I would probably do is take the current date and time, add the number of hours requested, and then send back the result = the final hour, as an integer, which may be stored in a global variable. In the routing script, the only thing you need to do is now() > date() + time(valueOfTheVariableStoringTheFinalHour, 0)

For instance, a customer calls in around 12:00 asking to switch off that particular branch of the call center, for 6 hours. The IVR will turn off that branch and will send 18 (12+6) as a result. The routing script will check for now() > date() + time(18,0) and will switch the branch back on when the condition is met.

G.

Joel, you could use the built-in ICM functions still...

  • hour() will give you the current hour if you don't include anything in the parenthesis.
  • minute() will give the current minute.

So, you could take in the number of hours the user would like to close for, add that to the value of hour(), concatenate with a comma and minute(), and evaluate it all in a time() function to get the time you need to store and compare against later.

In an admin script running every minute all day every day, I would do a check to see if you've enabled the manual close, and if so you check the current time() against the earlier stored time() to see if you can disable the manual close.

-Jameson

Jameson,

Thanks. I was hoping to find documentation that really explained the date and time function. That seems to be elusive. It would help if Cisco had a syntax diagram for each function along with better examples.

I was thinking it would be nice to use the now() function since that would give me an absolute date and time to compare against. But I am not confident I know how to add time to that (like 1 hour or 1 hour and 30 minutes). The time part is a fraction. I suppose I could just divide the number of hours by 24 and the minutes by 1440 and add those to the value of the now() function. I'll run some tests to see what I can figure out.

For adding 1 to the date, I was just going to use something like this:

Global.user_test_closed_manual = (date() + 1)

Then I would have an admin script with an IF statement looking for Global.user_test_closed_manual < date() to know when to open them back up.

Thanks.

Joel

Perhaps if you have the hours and minutes you'd like to close for, you can do something like this:

Global.user_test_closed_manual = now()+time(concatenate(8,", ",20))

In this example, I'm trying to add 8 hours and 20 minutes to the current time. You would probably substitute the variable names of the data you're getting from the caller for the "8" and "20" above. Haven't tested it, but if the time values run from 0 being midnight and 1 being the next midnight (like time values in Excel), this should work.

-Jameson

-Jameson

Jameson,

Your idea looks interesting.  I'll do some tests.  I would take the hours and minutes from CED and stuff them into a couple of Peripheral Variables and use that in your formula.  Definately looks like it would be easier to understand later on when I look at it again a year down the road.  It will take some time to try this, but I will let you know what I find.

Thanks.

Joel

Just took another look at the information for time(), it looks like my statement above should have looked more like:

Global.user_test_closed_manual = now()+time(8, 20)

Much simpler. Here's hoping it works as expected! Please post back once you've tested it.

-Jameson

-Jameson

I finally figured it out.  You cannot use any of the time functions like hour() and minute() because they return whole numbers.  The now() function returns the date in the whole number portion and the time as a fractionial part.  So I needed to convert the number of hours and minutes to a fractional part of a day.  Also, the global user variable I am storing it in must be a data type of float.  Here is how I was able to add hours and minutes to the current time and save the future reopen time in a user variable.

I set Call.PeripheralVariable1 to the number of hours via CED.

I set Call.PeripheralVariable2 to the number of minutes via CED.

I set Global.user_test_closed_float = now()+((Call.PeripheralVariable1/24)+(Call.PeripheralVariable2/1440))

I just did a quick test...

     time(Call.PeripheralVariable1,Call.PeripheralVariable2)

gives the same result as...

     ((Call.PeripheralVariable1/24)+(Call.PeripheralVariable2/1440))

time() returns the float fractional part of a day, and should add to now() just fine. I feel it's a little easier to read later. If you want to make it even easier to read, you could create additional variables (non-persistent User Variables probably), such as user_Hour and user_Minute, and end up with something like this:

     *Take in hours*

     Global.user_Hour = Call.CallerEnteredDigits

     *Take in minutes*

     Global.user_Minute = Call.CallerEnteredDigits

     Global.user_test_closed_float = now()+time(Global.user_Hour,Global.user_Minute)

-Jameson

-Jameson

Jameson,

Your method would give back the fractional value of a particular time of day (like 1:30 AM).  Adding that to now() would not produce a meaningful value.  What I am doing is using a relative amount of time (like 1 hour and 30 minutes) and adding that to the current time with the now() function.  In order to do that, I must convert the hours and minutes (the time duration we want to be closed) to a fractional value of one day (24 hours or 1440 minutes in a day).  Then I add that to the current time to calculate what time is 1 hour and 30 minutes from right now. That way I am using relative values rather than absolute values.  Relative values are easier because I don't need to worry about the time zone and DST of the router when setting this up for international locations like Australia which has it's own time zone and a wholly separate DST from the US.   Adding it to the now() function has the added advantage of not needing to worry about crossing over midnight to the next day since it also has the date built into it counting from January 1, 1601.  Think of it like setting a timer on your stove or putting money into a parking meter.  Eventually the time will expire and it will open back up.

Thanks for the ideas.  It helped get me moving in the right direction.  I still wish there was some good documentation on this.  It would eliminate a lot of trial and error.

Joel

Update...  After thinking about it some more, I see you are correct.  Using time(1,30) would give the same numerical result as (1/24)+(30/1440).   I was thinking of it like an absolute date / time.  But the time function would only return the fractional time portion without the whole number date portion.  So yes, your method would work too.  So it comes down to style.  I'll just have to put lots of comments in the script so the next poor soul that looks at it does not get all confused.

Thanks.

Joel

Gergely,

Thanks for your reply.  I wanted to use an administration script to do the checking as to when to open them back up.  I think I can do what I need to with the built-in functions, I just cannot find good documentation.

Joel

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: