Open In App
Related Articles

Hex() and Oct() Function Function in MS Access

Improve Article
Improve
Save Article
Save
Like Article
Like

1. Hex() Function : Hex() Function in MS Access is used to returns a String representing the hexadecimal value of a number. Syntax :

Hex(number)

Parameter : This method accepts one parameter as mentioned above and described below :

  • number : It is any valid numeric expression or string expression.

Returns : If the number is null it returns null, if the number is Empty then it returns Zero (0). Otherwise it returns a String representing the hexadecimal value of a number. Note : If number is not already a whole number, it is rounded to the nearest whole number before being evaluated. Example-1 : Hexadecimal representation of 2.

SELECT Hex(2) AS HexNumber;

Output :

HexNumber
2

Example-2 : Hexadecimal representation of 13.

SELECT Hex(13) AS HexNumber;

Output :

HexNumber
D

Example-3 : Hexadecimal representation of 1134.80.

SELECT Hex(1134.80) AS HexNumber;        

Output :

HexNumber
46F

2. Oct() Function : Oct() Function in MS Access is used to returns a String representing the octal value of a number. Syntax :

Oct(number)

Parameter : This method accepts one parameter as mentioned above and described below :

  • number : It is any valid numeric expression or string expression.

Returns : If the number is null it returns null, if the number is Empty then it returns Zero (0).Otherwise it returns a String representing the octal value of a number. Note : If number is not already a whole number, it is rounded to the nearest whole number before being evaluated. Example-1 : Octal representation of 7.

SELECT Oct(7) AS OctNumber;                

Output :

OctNumber
7

Example-2 : Octal representation of 111.45.

SELECT Oct(111.45) AS OctNumber;                

Output :

OctNumber
157
Unlock the Power of Placement Preparation!
Feeling lost in OS, DBMS, CN, SQL, and DSA chaos? Our Complete Interview Preparation Course is the ultimate guide to conquer placements. Trusted by over 100,000+ geeks, this course is your roadmap to interview triumph.
Ready to dive in? Explore our Free Demo Content and join our Complete Interview Preparation course.

Last Updated : 29 Dec, 2022
Like Article
Save Article
Similar Reads