cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1702
Views
20
Helpful
7
Replies

UCCX 9 How to check if Expiration date is not Older than current date

nkobayashi123
Level 1
Level 1

Good afternoon everyone. 

I forgot to place a credit card expiration date check process in my script...    My script works like this...

     1. A customer manually enter his/her credit card expiration date

     2. Outcome is MM/YYYY

     3. I need to place a checking process if MM/YYYY is not older than current date.

I have my expiration date as    Set = expirationdate = string.valueOf(ExpMonth) + "/" + string.valueof(expYear)  

after that, it gives mye the MM/YYYY value.  Then, how can I check if expiration date is not older than today?

I really appreciate your input.

thank you so much

nana

1 Accepted Solution

Accepted Solutions

Here is a sample script which shows how you compare two dates together

Variables

Prompt enter_card_expiration = P[enter_card_expiration.wav]

Prompt card_is_valid = P[card_is_valid.wav]

Prompt card_has_expired = P[card_has_expired.wav]

String caller_input = ""

Date expiration_date = D[now]

Date today = D[now]

Script

Start

Accept (--Triggering Contact--)

Ask for expiration date:

/* Caller is asked to enter MMYY format */

caller_input = Get Digit String (--Triggering Contact--)

  Successful

    Set expiration_date = d[caller_input.substring(0, 2) + "/1/" + caller_input.substring(3)]

    If (expiration_date.year > today.year || (expiration_date.year == today.year && expiration_date.month >= today.month))

      True

        Goto Card is valid

      False

        Goto Card has expired

  Timeout

    Goto Ask for expiration date

  Unsuccessful

    Goto Ask for expiration date

Card is valid:

Play Prompt (--Triggering Contact--, card_is_valid)

Goto End of script

Card has expired:

Play Prompt (--Triggering Contact--, card_has_expired)

Goto End of script

End of script:

Terminate (--Triggering Contact--)

End

Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.

View solution in original post

7 Replies 7

Anthony Holloway
Cisco Employee
Cisco Employee

There's two three ways really:

1. Method Based Approaches

Date1.before(Date2) (Before)

Date1.after(Date2) (After)

Date1.compareTo(Date2) (0 = On; -1 = Before; 1 = After)

2. Inequality Checks

Date1 < Date2 (Before)

Date1 <= Date2 (On or Before)

Date1 > Date2 (After)

Date1 >= Date (On or After)

EDIT: Third way

3. Date objects contain a time value, down to the msec, as well as Date, and when you compare two Date objets, these Times are also considered.

Example:

Set d1 = D["1/1/2013 3:45PM"]

Set d2 = D["1/1/2013 4:45PM"]

d1 < d2 is True

d1 > d2 is False

d1 == d2 is False

Therefore you will either need to zero out the time portion of their values at instation like so:

Set d1 = D["1/1/2013 12:00:00 AM"]

Or after with the following methods:

Do d1.setHours(0)

Do d1.setMinutes(0)

Do d1.setSeconds(0)

Or you will need to use a different comparison method like so:

If (d1.year > d2.year || (d1.year == d2.year && d1.month > d2.month))

Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.

Hi Anthony, thank you for super quick reply

I guess I'm missing here...   I tried to do  following..

Set Today = D[now]

if (ExpirationDate > Today) then

True-> Go to Next

False-> Go to ReEnter

But ExpirationDate is MM/YYYY and D[now] is MM/YY format.  I don't know if that is the reason but it goes to re enter...

or I might be doing wrong here.... 

What data type is your variable ExpirationDate?  Is is Date or String?  If String, you will need to create a new variable of type Date, and then set it's value to that which is held in the String value.

One way to do that is:

Set my_date = D[my_string]

But that only works if the String value is in the proper format.

The supported formats (according to the Vol 3 Programming Guide) are:

DateDesignator:
FullDatePattern:
Defined by the pattern "EEEE, MMMM d, yyyy" LongDatePattern:
Defined by the pattern "MMMM d, yyyy" MediumDatePattern:
Defined by the pattern "MMM d, yyyy" ShortDatePattern:
Defined by the pattern "M/d/yy"

So, you would need to add in a day value to your MM/YYYY.

You could easily add in the 1st day of the month like this:

Set my_date = D[ExpirationDate.substring(0, 2) + "/1/" + ExpirationDate.substring(3)]

That should yeild a date object, and then you can do your inequality test in the If Step.

Let me know if you need more help.  I'll be out for the weekend mostly, but will check back on Monday for sure.

Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.

Thank you for your reply. 

As you suspected, my ExpirationDate is "string".     I have set the ExpirationDate as

     Set ExiprationDate = String.valueOf(ExpirationMonth) + "/" + String.valueOf(ExpirationYear)

and outcome is "MM/YYYY".

I tried to convert the string to date but I guess I'm not doing right...

I have made this change to match the D/D/YY format

     Set DateExpiration = D[ExpirationDate.Substing(0,2) + "/1/" + ExpirationDate.substring(3)]  

and outcome is "1/1/14"

From here, I'm not sure how to cmpare DateExpiration and Current date .....

I really appreciate your help.  Thank YOU so much

Nana

Here is a sample script which shows how you compare two dates together

Variables

Prompt enter_card_expiration = P[enter_card_expiration.wav]

Prompt card_is_valid = P[card_is_valid.wav]

Prompt card_has_expired = P[card_has_expired.wav]

String caller_input = ""

Date expiration_date = D[now]

Date today = D[now]

Script

Start

Accept (--Triggering Contact--)

Ask for expiration date:

/* Caller is asked to enter MMYY format */

caller_input = Get Digit String (--Triggering Contact--)

  Successful

    Set expiration_date = d[caller_input.substring(0, 2) + "/1/" + caller_input.substring(3)]

    If (expiration_date.year > today.year || (expiration_date.year == today.year && expiration_date.month >= today.month))

      True

        Goto Card is valid

      False

        Goto Card has expired

  Timeout

    Goto Ask for expiration date

  Unsuccessful

    Goto Ask for expiration date

Card is valid:

Play Prompt (--Triggering Contact--, card_is_valid)

Goto End of script

Card has expired:

Play Prompt (--Triggering Contact--, card_has_expired)

Goto End of script

End of script:

Terminate (--Triggering Contact--)

End

Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.

Thank YOU so much!!   It is working now     I would love to give you 10 stars!!!!!

Nana

You are very welcome.  I'm happy that you have your solution working now.  Take care.

Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.

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: