Home page
 
 Home 
 ASP 
 PHP 
 SQL 
 HTML 
 JavaScript 
 Search 
 Contact 
 
Search
or browse popular tags
Access Functions
Subscription

Sign up for the free email newsletter for new tips, tutorials and more. Enter your email address below, and then click the button.

Privacy Policy

RSS Twitter

Access: Sgn Function

Print

In Access, the Sgn function returns a variant indicating the sign of a number.

The syntax for the Sgn function is:

Sgn( number )

The argument number can be any valid numeric expression. Its sign determines the value returned by the Sgn function.

If number is greater than zero, the Sgn function will return 1.

If number is equal to zero, the Sgn function will return 0.

If number is less than zero, the Sgn function will return -1.

Example

Sgn (2.38)       returns 1
Sgn (0)          returns 0
Sgn (-2.38)      returns -1

VBA Code

Dim MyNumber As Integer
MyNumber = Sgn(3.40)

This example uses the Sgn function to determine the sign of a number. Now the MyNumber variable would contain the value 1.

SQL query

You can also use the Sgn function in a query.

SELECT Sgn(-24.65) AS Expr1, Sgn([OwnerID]) AS Expr2 
FROM Orders


If you'd like to see how it works, enter SQL statement and press Execute
 




Tags:

Add To: Add to dzone dzone | Digg this digg | Add to del.icio.us del.icio.us | Stumble it stumbleupon

  • Comments





Copyright © 2005-2014             www.WebCheatSheet.com All Rights Reserved.