The document outlines various numeric and date/time functions used in SQL. It details the syntax and examples for functions like POWER, ROUND, TRUNCATE, MOD, CURDATE, and DAYOFWEEK, among others. Each function is described with its purpose and expected output for clarity.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
3 views3 pages
Numeric Function
The document outlines various numeric and date/time functions used in SQL. It details the syntax and examples for functions like POWER, ROUND, TRUNCATE, MOD, CURDATE, and DAYOFWEEK, among others. Each function is described with its purpose and expected output for clarity.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3
4NUMERIC FUNCTION
These functions perform on numeric values and return numeric
values. POWER(x , y ) /POW(x , y) : This function returns the value of x raised to the power of y . Syntax : SELECT POW ( x , y ) ; Eg : SELECT POW ( 2 , 4 ) ; O/P : 16 ROUND ( x ) : This function rounds the argument x to the nearest integer . Syntax : SELECT ROUND (x) ; Eg : SELECT ROUND ( 2.453) ; O/P : 2 ROUND ( x , d ) : This function returns the argument x to d decimal places . Syntax : SELECT ROUND ( x , d ) ; Eg : SELECT ROUND ( 2.553 , 1); O/P : 2.6 TRUNCATE (x , d) :This function returns the number x truncated d decimal places . Syntax : SELECT TRUNCATE (x , d ); If d = 0 ,The result has no fractional part. If d = -ve , It causes d digits left of the decimal point of the value x to become zero. If d = +ve , It causes d digits right of the decimal point of the value x . Eg : 1)SELECT TRUNCATE (2.564 ,0); O/P : 2 Eg : 2) SELECT TRUNCATE (2.564 , 1); O/P :2.5 Eg : 3) SELECT TRUNCATE(12.564 ,-1); O/P : 10 MOD(x , d) : This function returns the reminder of a division. Syntax : SELECT MOD (x , d); Eg : SELECT MOD( 160 , 30); O/P : 10 DATE & TIME FUNCTIONS These functions are required to manipulate date & time type of values. CURDATE() : This function returns current date in yyyy-mm-dd format . Eg: SELECT CURDATE(); O/P : 2020-10-29 DATE (EXP) : This function extracts date part from date or datetime expression. Eg : SELECT DATE (‘2020-10-29 12:45:15’); O/P : 2020-10-29 MONTH(date) : This function returns the month no. from date argument . Eg : SELECT MONTH (‘2020-10-29’); O/P : 10 DAYOFMONTH(date) :This function returns the day of the month of date argument. (1-31) Eg : SELECT DAYOFMONTH (‘2020-10-29’); O/P : 29 DAYOFWEEK(date) : This function returns the day of the week of date argument . i.e : 1 - Sun day 2 – Mon day -------------- etc. Eg : SELECT DAYOFWEEK(‘2020-10-29’); O/P : 5 DAYOFYEAR(date) : This function returns the day of the year of the date argument. Eg : SELECT DAYOFYEAR(‘2020-10-29’); O/P : 301 DAYNAME(date) : This function returns the day name of date argument . Eg : SELECT DAYNAME(‘2020-10-29’); O/P : Thurs day NOW() : This function returns current date & time in YYYY-MM- DD HH-MM-SS format. Eg : SELECT NOW(); O/P : 2020-10-29 01:15:45 SYSDATE() : This function returns same value as NOW(); Eg : SELECT SYSDATE() ; O/P : 2020-10-29 01:16:45