Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Can you have a IIF(IsDate together?

Posted on 2008-10-12
3
Medium Priority
?
303 Views
Last Modified: 2012-06-27
I have a variable that would either be blank or have a date and the variable name is VdtmResponse

The code is written like

testoutput = iif(IsDate(VdtmResponse), 1, 2)

But I get the following error...

Type mismatch: 'iif'

Any ideas?
0
Comment
Question by:Zantis
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 82

Accepted Solution

by:
hielo earned 2000 total points
ID: 22696672
Are you doing this on vb or on a sql statement? IIF is NOT a vb contruct. It works on db only.

Dim testoutput
testoutput=2
If Trim(VdtmResponse)<>"" Then
testoutput=1
End
0
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 22696674
IIF is not available in vbscript, you need to have a customize function, like this:

<%

function IIF(cond, v1, v2)
    if cond then
          IIF = v1
    else
         IIF = v2
   end if
end function
%>

then:


testoutput = iif(IsDate(VdtmResponse), 1, 2)
0
 
LVL 6

Expert Comment

by:carlsiy
ID: 22696828
testoutput = iif(IsDate(VdtmResponse)=True, 1, 2)
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question