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!