0% found this document useful (0 votes)
43 views2 pages

Describe The Use of Following Oracle Date Functions With An Example

Sysdate returns the current date and time of the system running the database. Current_date returns the current date according to the time zone of the SQL session. Systimestamp returns the current date and time including fractions of seconds and time zone. Round and trunc are used for date calculations - round returns the next rounded value while trunc scraps digits. To_date converts a string to a date value using a specified format, and to_char converts a date or number to a string using a specified format.

Uploaded by

Ajay Joshi
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)
43 views2 pages

Describe The Use of Following Oracle Date Functions With An Example

Sysdate returns the current date and time of the system running the database. Current_date returns the current date according to the time zone of the SQL session. Systimestamp returns the current date and time including fractions of seconds and time zone. Round and trunc are used for date calculations - round returns the next rounded value while trunc scraps digits. To_date converts a string to a date value using a specified format, and to_char converts a date or number to a string using a specified format.

Uploaded by

Ajay Joshi
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/ 2

Describe the use of following oracle date functions with an example.

Sysdate
Current_date
SYSTIME STAMP
ROUND and TRUNC in date calculation
TO_DATE and TO_CHAR formatting
1. Sysdate
Sydate in Oracle /PLSQL is used to return the current date and time of the system in which
the database is configured.
Example:Returns the System date and employee from the table
Select SYSDATE, id from employee Where emp_id >100;
2. Current_date
Current_date in Oracle /PLSQL is used to return the current date of the time zone of the
existing or running SQL session.
Example:
Select current_date from employee Will return: 16-JAN-2010 10:14:33
3. SYSTIMESTAMP
SYSTIMESTAMP in Oracle /PLSQL is used to return the current system (on which the
database is configured) date and time which includes fractions of seconds and time zone.
Example:
Select SYSTIMESTAMP from employee Will return: 16-JAN-10 12.38.55.538741 PM
-08:00
4. ROUND and TRUNC in date calculation
ROUND in Oracle /PLSQL is used to return the next rounded value of a number. The number
of decimal places to be rounded is determined by a parameter.
Example:
ROUND(120.411) will return 120
ROUND(120.411, 1) will return 120.4
Select ROUND(salary_amt,2) from employee
TRUNC in Oracle /PLSQL is used to scrap or truncate the number of digits specifed. The
number of digits to be truncated is determined by a parameter.
Example:
TRUNC(120.411, 1) will return 120.41
Select TRUNC(salary_amt,2) from employee

5. TO_DATE and TO_CHAR formatting


TO_DATE function in Oracle /PLSQL is used to convert a given string in DATE format.
Example:
to_date('2010/07/09', 'yyyy/mm/dd') would return a date value of Jan 10, 2010.
TO_CHAR function in Oracle /PLSQL is used to convert a given number (DATE or number)
to string.
Example:
to_char(sysdate, 'FMMonth DD, YYYY'); would return Jan 10, 2010'
Here, FM parameter suppresses the blank spaces and zeros.

You might also like