Odd or even test

# Thread: Odd or even test

1. Senior Member
Join Date
Dec 1969
Posts
417

## Odd or even test

Does VBScript have a function built in for detecting whether a given integer is odd or even? If so what is it please? If not, what is the best way to simulate what it would do please?<BR><BR>Thanks<BR>Ben

2. Senior Member
Join Date
Dec 1969
Posts
96,118

## num MOD 2 = 0 (even)

If num MOD 2 = 0 Then<BR> Response.Write num & " is even"<BR>Else<BR> Response.Write num & " is odd"<BR>End If<BR><BR><BR>

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

## MOD

mod function......<BR><BR>something like this, i believe:<BR><BR># MOD 2<BR><BR>basically, if i&#039;m not mistaken, this function returns the remainder of the # divided by 2 (or whatever number you put there). if it returns 1, you know it&#039;s odd. if it returns 0, then you know it&#039;s even......as any even number divided by 2 has no remainder.<BR><BR>could be wrong, but it&#039;s worth a shot.

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

## tie goes to ................bill <nm>

.

5. Senior Member
Join Date
Dec 1969
Posts
96,118

## Since this is running on...

...SQL Server, and since a DATETIME value in SQL Server is accurate to 3.33 milliseconds...there aren&#039;t any ties. &#060;snicker /&#062;<BR><BR>Here:<BR>http://msdn.microsoft.com/library/en-us/tsqlref/ts_da-db_9xut.asp<BR><BR>

6. Senior Member
Join Date
Dec 1969
Posts
96,118

## This is REALLY funny!

If you click on "Recent Posts" under Site Index, it shows *YOUR* message as arriving first!!!<BR><BR>Talk about inconsistency in the ORDER BY clause!<BR><BR>

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

## i noticed the same thing.....<nm>

.

8. Senior Member
Join Date
Dec 1969
Posts
417

## RE: i noticed the same thing.....<nm>

Cheers chaps, nice work, I&#039;ll go and try it out

#### Posting Permissions

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