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.
1. 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;
2. 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 time of the system (HH24:MI:SS). This query upon execution will give you system current date along with the system current time.
3. 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 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!
SQL Script and Presentation used
You can DOWNLOAD SQL script and presentation used in the Video and in this article.
SQL Script used in Video and in this article
I have used copy cloud to share these resourses. You can also join copy cloud and get 15GB free cloud storage for lifetime. If you will use this referal link
You will get 5GB extra free cloud storage means total 20GB free cloud storage.