If Statement

1. Senior Member
Join Date
Dec 1969
Posts
360

## If Statement

For some reason I can&#039;t get vMonthCount = 1. Can someone point out what I&#039;m missing besides my brain.<BR><BR>vMonthCount = DateDiff("m", rsAvg("vMinDate"), Now)<BR>If vMonthCount = "" then<BR> vMonthCount = 1 <BR>End IF<BR>IF vMonthCount &#060; 1 THEN <BR> vMonthCount = 1 <BR>END IF

2. Senior Member
Join Date
Dec 1969
Posts
1,407

## RE: If Statement

what do you get when you response.write vMonthCount?<BR><BR>i mean, the obvious answer (and i&#039;m sure you&#039;re aware of this) is that vMonthCount &#062;= 1

3. Senior Member
Join Date
Dec 1969
Posts
2,958

## RE: If Statement

try<BR><BR>vMonthCount = DateDiff("m", rsAvg("vMinDate"), Now())

4. Senior Member
Join Date
Dec 1969
Posts
11,247

## RE: If Statement

Datediff (I believe) always returns a value so checking for "" is wrong!<BR>Also why do it as you are setting vMonthCount to 1 no matter what!<BR>

5. Senior Member
Join Date
Dec 1969
Posts
1,407

## good eye, doug

missed that.....<BR><BR>knight: is he actually always setting it equal to 1 no matter what? can&#039;t datediff return a negative value or a zero?

6. Senior Member
Join Date
Dec 1969
Posts
11,247

## RE: good eye, doug

&#062;can&#039;t datediff return a negative value or a zero? <BR>yep I looked it up after writing! <BR>(duh! better to look up then write!!!)

7. Senior Member
Join Date
Dec 1969
Posts
360

## RE: If Statement

Wow thank you for the responses! The reason I&#039;m checking vMonthCount is because I&#039;m dividing by it later on, so you can divid by zero or "" because you get an error.

8. Senior Member
Join Date
Dec 1969
Posts
360

## RE: If Statement

the weird thing is that when I response.write vMonthCount I get nothing.

9. Senior Member
Join Date
Dec 1969
Posts
360

## Figured it out!

Thank you for all your help!

#### Posting Permissions

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