From the course: Oracle Database 12c: Basic SQL

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Using SYSDATE

Using SYSDATE - Oracle Database Tutorial

From the course: Oracle Database 12c: Basic SQL

Start my 1-month free trial

Using SYSDATE

- Oracle has a special, built-in function called sysdate. Which allows us to retrieve and format the current date and time of the Oracle database server. Let's see it in action. Let's start with the simplest example. Select sysdate from dual. Running this query will display the current date and/or time depending on how my session NLS or date/time parameters have been configured. We can override the default values and get a sysdate output that is formatted to our specific requirement using a combination of the to_char functions with sysdate. So let's add to_char to our query, specifying sysdate as the first parameter for the function, comma and a formatting mask, such as: day day/MON/year year year year so that we'll get 4 digits representing the year, HH24:MI:SS, which signifies a time-formatting mask. Running this query again, will show us the current date and time. Running the query again, an additional time, will show us an updated value. We can, of course, change the formatting…

Contents