0% found this document useful (0 votes)
15 views

Number Date Student Notes

The document discusses several Oracle number functions including ROUND, TRUNC, and MOD. ROUND rounds a number to a specified number of decimal places. TRUNC truncates a number to remove anything after a specified decimal place. MOD returns the remainder of a division operation. Examples are provided of using these functions with dates and numbers.

Uploaded by

MazMoh
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Number Date Student Notes

The document discusses several Oracle number functions including ROUND, TRUNC, and MOD. ROUND rounds a number to a specified number of decimal places. TRUNC truncates a number to remove anything after a specified decimal place. MOD returns the remainder of a division operation. Examples are provided of using these functions with dates and numbers.

Uploaded by

MazMoh
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

The Number Functions (ROUND,TRUNC,MOD) SELECT SYSDATE FROM DUAL; **number functions accept numeric input and return

numeric values ROUND(numericvalue,decimal places) ** if the rounding value is negative, start at the decimal moving left then place an "imaginary" decimal there and round. 45.926, 2 = 45.93 45.926, 1 = 45.9 45926, -2 = 45900 45926, -3 = 46000 TRUNC(numbericvalue, cut off at decimal place) **if the round decimal place value or the cut off at decimal place is omitted it is truncated to zero places ROUND/TRUNC(date,'MONTH') ROUND/TRUNC (date,'YEAR') SELECT last_name,hire_date, ROUND(hire_date,'MONTH'), TRUNC(hire_date,'MONTH') FROM employees WHERE last_name = 'King'; MOD(dividend, divisor) MOD(2443,34) MOD(salary,1.5) The purpose of the DUAL table and the need to specify an alias to display data: DATES(arithmetic with dates,round, truncate) DD-MON-YY is the default format stores in numeric format and stored the the database to the second. (pg3-17) date + number it is in days SELECT last_name, hire_date + 90 AS "Review" FROM employees; *is a value odd or even?

date - date SELECT SYSDATE - hire_date AS "Days Worked" FROM employees WHERE last_name = 'King';
***ADD THE ROUND/TRUNC FUNCTION TO ELIMINATE THE DECIMAL PLACES ***DIVIDE BY 365 to SHOW YEARS

MONTHS_BETWEEN SELECT MONTHS_BETWEEN (SYSDATE, hire_date) AS "Months" FROM employees WHERE last_name = 'King'; SELECT MONTHS_BETWEEN ('25-DEC-02', '25-DEC-01') AS "Months" FROM DUAL; ADD_MONTHS SELECT last_name, hire_date,ADD_MONTHS(hire_date,6)AS "Evaluation" FROM employees WHERE last_name = 'King'; SELECT ADD_MONTHS ('25-DEC-02', 5) AS "Months" FROM DUAL; NEXT_DAY SELECT NEXT_DAY('13-FEB-02','TUESDAY')AS "Back to School" FROM DUAL; LAST_DAY SELECT LAST_DAY('13-FEB-02')AS "Payday" FROM DUAL;

You might also like