0% found this document useful (0 votes)
11 views6 pages

DBMS Ex4

Copyright
© © All Rights Reserved
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% found this document useful (0 votes)
11 views6 pages

DBMS Ex4

Copyright
© © All Rights Reserved
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/ 6

DATE: / /

1201

Experiment-4:
Queries using conversation functions (To-char,To-
date,To_no)stringfunctions(L pad,R pad,R trim,substring,instr)
Date
functions(sysdate,nextdate,add_months,least_date,months_between,
least,greatest,trunc,round)
To_char:
IT converts date Values into characters string values.
Query:
Ex:sql>select To-char(sysdate) from dual;

To_date:
IT converts string Values into characters date
Query:
Ex:sql>select To-date(‘jan 3 1998’,’month dd, yy)from dual;

String functions:
Lower:
It converts the string value to lower
case. Query:Sql>select lower(‘SAI’) from
dual;

Upper:
It converts the string value to upper case.
Query:Sql>select upper(‘SAI’) from dual;

Page no:
DATE: / /
1201

Concat: It concates two strings.


Query: sql> select concat(‘sai’,’reddy’) from dual;

INITCAP: It returns capital of first letter in a string.


Query: sql> select initcap(’reddy’) from dual;

length: It returns lengthof a string.


Query: sql> select length(’reddy’) from dual;

INSTR: It returns position of a character


Query: sql> select instr(’reddy’) from dual;

SUBSTRING: It returns substring.


Query: sql> select substr(‘information’,2) from dual;

R pad: It specifies length in right side


Query:
Sql> select rpad(‘sai’,10,’******’) from dual;

Page no:
DATE: / /
1201

L pad: It specifies length in left side


Query:
Sql> select lpad(‘sai’,10,’******’) from dual;

R trim: It is used to remove all specify characters from left side of the string.
Query:
Sql> select rtrim(’******’ ,‘sai’,’***’,’*’) from dual;

Date functions:
SysDATE():
It returns the current date in the
system. Query:
Sql> select sysdate from dual;

NextDAy():
It returns the next date the next coming day.
Query:
Sql> select nextday (‘Sunday’)from dual;

Page no:
DATE: / /
1201

Add_months():
It returns the next date after adding number of months in the arguments.
Query:
Sql>select add_months(sysdate,5) from dual;

Last_day():
It will takes a date value as an argument and returns the last day of month in that
date. Query:
Sql> select last_date(sysdate) from dual;

Months_between():
It returns the number of months between given two dates.
Query:
Sql>select months_between(‘2-feb-2021’,’2-oct-2020’) from dual;

Least():
It returns least value from the given arguments or attributes.
Query:
Sql>select least(300,17,2121) from dual;

greatest():
It returns maximum value from the given arguments or attributes.
Query:
Sql>select greatest(17,100,2121) from dual;

Page no:
DATE: / /
1201

trunc():
It returns a date value truncated to a specified
unit. Query:
Sql>select trunc(sysdate,’mm’) from dual;

Round():
It returns round a number to a specified length or precision.
Query:
Sql>select round(23.49,0) from dual;

To_char():
It convert the given data type attribute values to text and return the date in the specific
Format.
Query:
Sql>select to_char(sysdate,’yy-mm-dd’) from dual;
DATE: / /

Page No:

You might also like