CDate Conversion Problem

if Request.Form("ret") = "" then
                         dtret = "8/9/2004"
                      end if
                      if Request.Form("ret2") = "" then
                         dtret = "5/31/2005"
                      end if

                         
                      strSQLEF = "Calendar.dbo.kwsSP_GetEventsFound '" & CDate(dtret) & "', '" & CDate(dtret2) & "', '"  & "%" & strevent & "%" & "', '"  & strevent & "%"  & "', '"

Error:

Error Type:
Microsoft VBScript runtime (0x800A000D)
Type mismatch: 'CDate'
/htdocs/calendar/events_found.asp, line 271
kwcowboy1226Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Arthur_WoodCommented:
it appears that you are using SQL Server as the database?  in which case, you code should look like this:

strSQLEF = "Calendar.dbo.kwsSP_GetEventsFound '" & dtret & "', '" & dtret2 & "', '"  & "%" & strevent & "%" & "', '"  & strevent & "%"  & "', '"


SQL Server does NOT recognize Date type values from VBScript, as DateTime values in SQL Server.

a VBScript Date type value is actually being passed as a NUMBER with a decimal point, ehich is not a datetime value in SQL Server.

AW
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jaime OlivaresSoftware ArchitectCommented:
You don't need CDate since both dret and dret2 are strings.
The concatenating operator & needs string, so will be enough:
strSQLEF = "Calendar.dbo.kwsSP_GetEventsFound '" & dtret & "', '" & dtret2 & "', '"  & "%" & strevent & "%" & "', '"  & strevent & "%"  & "', '"

BR,
Jaime.
0
Carlos LimonggiSoftware developerCommented:
you could put CDate(dtret)into a new var type string and then use the new string var(date previously validated with cdate) into the sql sentence concatenated with '"& newvar &"'
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.