Sysdate Function In Oracle Database by manish sharma

Sysdate Function In Oracle Database

Sysdate is a function in oracle database which returns system current date and time.
So letā€™s move ahead and see how we can retrieve system current date and time using Sysdate function of Oracle Database.

How to retrieve system current date using Sysdate function

By default, Sysdate function returns system current date in Oracle default date format which is DD-MON-RR

SELECT  Sysdate  FROM  dual;

How to retrieve current date and time using Sysdate function

Using Sysdate function you can also retrieve system current time along with the date. Let’s see how:

SELECT  TO_CHAR(Sysdate, ā€˜DD/MON/YYYY HH24:MI:SSā€™)  FROM  dual;

In the above query, in order to print the system current time along with the date, we used TO_CHAR() conversion function where we passed Sysdate as the first parameter of the function and a date format. As you can see in the date format, we have explicitly specified that along with the date (DD/MON/YYYY) we also want the time of the system (HH24:MI:SS). This query upon execution will give you system current date along with the system current time.

How to retrieve system current time using Sysdate function

Itā€™s also possible to find out just the current time of your system using Sysdate function of Oracle database. 

SELECT  TO_CHAR(Sysdate, ā€˜HH24:MI:SSā€™)  FROM  dual;

Query is pretty similar to the previous one, the only difference is the format which we have specified in the TO_CHAR() conversion function. As you can see, unlike the previous query this time format involves elements only for the system time. This query will return you the systemā€™s current time on execution. 
So thatā€™s it guys. Hope you find this blog helpful. Kindly please share it on your social media and help me reach out to more people. Thanks & have a great day!