Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.

# Thread: Expiry Date Cause String Mismatch

1. ## Expiry Date Cause String Mismatch

I have a piece of asp code that is validating a credit card expiry date. The values from "CC_expmonth" value and "CC_expyear" value are checked against todays date and returns an error is expired. I am getting a "Type mismatch: '[string: "//"]' " error which I have narrowed down to be associated with this bit of code...

Code:
```DateDiffTest=DateDiff("D", Date, ConcDate)
if DateDiffTest =< 0 then
Reason2 = "<strong>ERROR:</strong> Credit Card Expired. "
InputError=InputError+1
end if```
Here is the entire code in question:

Code:
```dim CCExpDate,LLDate,ConcDate
'Concatenate date str for compare with CDate vals, if this is needed
dim DaysInMos,DateDiffTest

'Select CASE based on card month input from usr
Select Case CC_expmonth
Case "1"
DaysInMos="31"
Case "2"
'forgot to calc for leap yr for day diff in Feb
'Every year divisible by 4 IS a leap year.
'But every year divisible by 100 is NOT a leap year
'Unless the year IS ALSO divisible by 400, then it is still a leap year.
'i.e., 1800, 1900, 2100, 2200, 2300 and 2500 are NOT leap years, year 2000 and 2400 are.

'establish generic days-in-mos for Feb
DaysInMos=28

'check for Leap Year and chg days to 29 instead
right_year_divided=CC_expyear/4
if right_year_divided = cint(right_year_divided) then
DaysInMos=29
end if

if right(CC_expyear,2)="00" then
right_year_divided=CC_expyear/400

if right_year_divided = cint(right_year_divided) then
DaysInMos=29
end if ' I checked of year values
end if ' I checked for new century

Case "3"
DaysInMos="31"
Case "4"
DaysInMos="30"
Case "5"
DaysInMos="31"
Case "6"
DaysInMos="30"
Case "7"
DaysInMos="31"
Case "8"
DaysInMos="31"
Case "9"
DaysInMos="30"
Case "10"
DaysInMos="31"
Case "11"
DaysInMos="30"
Case "12"
DaysInMos="31"
End Select

'Concantenate cc exp str for compare
ConcDate = CC_expmonth & "/" & DaysInMos & "/" & CC_expyear

'Check differences in Card Date and Now
'Complain if diff is 0 or neg num
DateDiffTest=DateDiff("D", Date, ConcDate)
if DateDiffTest =< 0 then
Reason2 = "<strong>ERROR:</strong> Credit Card Expired. "
InputError=InputError+1
end if

'===================================================

if InputError = 0 then```

I have found this bit of info from ASP 101 -- LINK

"So... if there's really only one data type, what does a type mismatch mean and why am I writing a sample about data types? Well... a type mismatch occurs when you try and do something inappropriate like for example divide a number by a string or pass a string to a function that only processes numbers! You may have noticed how I tend to name my variables starting with a lower case prefix. This is one way programmers attempt to keep track of what type of data a certain variable is supposed to contain in an attempt to not get type mismatches."
I have not a clue how to rewrite this little bit of code to to remove this MISMATCH error. Can someone please lead down the right path?

THANKS!!

• Have you tried to do a response.write ConcDate to ensure that it is indeed what you think it is?

basically your error message is telling you that it is not what you think it is

• try making sure that ConcDate is a date value
Code:
```'Concantenate cc exp str for compare
ConcDate = CC_expmonth & "/" & DaysInMos & "/" & CC_expyear
If isDate(ConcDate) Then
ConcDate = CDate(ConcDate)
Else
response.Write("Invalid expiration date")
End If```

•

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•