Describe The Use of Following Oracle Date Functions With An Example
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