Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Can you have a IIF(IsDate together?

Posted on 2008-10-12
3
Medium Priority
?
305 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
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 54

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Screencast - Getting to Know the Pipeline
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

927 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