Other related articles:

Recently viewed articles:

SQL SYSDATE Function

SQL SYSDATE function is used to get current date and time. It returns current date and time on server. SQL SYSDATE function can be combined with other functions and can be used in many ways such as to get age of employees from their date of birth, to find number of years employee worked for,

Example:
The following SQL SYSDATE Function will return current date and time from server:

SELECT SYSDATE FROM dual;

Example 2:
The following will return age for each employee based on their date of birth from employee table using SQL SYSDATE function:

SELECT ROUND (MONTHS_BETWEEN (SYSDATE, birth_date)/12) AS age FROM employee;

Output:
sql sysdate image1

Example 3:
The following will returns same results as second example except that it uses different functions:

SELECT TO_CHAR (SYSDATE,'YYYY') - TO_CHAR (birth_date, 'YYYY') AS age FROM employee;

Output:
sql sysdate image2