The PLSQL SYSDATE function will returns current system date and time on your database. There is no any parameter or argument for the SYSDATE function. The SYSDATE function returns a date value. Note that the SYSDATE function return date and time as “YYYY-MM-DD HH:MM:SS” (string) or as YYYYMMDDHHMMSS (numeric).
Above example will display current date from system on database. It will execute the Syntax ‘Sysdate’ from dual, which act as dummy table and display date only in default format. In above query ‘System_date’ act as Alias Name i.e., Temporary Name of that specified column.
1. Display both Date and Time –
SELECT TO_CHAR(Sysdate, Format_Of_Date_and_Time) AS Alias_Name FROM Dual Format_Of_Date_and_Time: DD-MM-YYYY HH:MM:SS MM-DD-YYYY HH:MM:SS YYYY-MM-DD HH:MM:SS DD-MON-YYYY HH:MM:SS MON-DD-YY HH:MM:SS DD-MM-YYYY HH24:MM:SS (For 24hr time Format)
In above example, it will display both date as well as time on database in specified format. TO_CHAR() Function is basically helpful to convert System date into date and time of specified format. Here ‘System_date_time’ also act as Alias Name and display both date and time in defined column.
2. Display Consecutive Dates from Current Date using Level –
SELECT Sysdate+Level-1 FROM Dual CONNECT BY Level<=n
Where n is consecutive number of days.
For display of consecutive number of dates, we can use SYSDATE with LEVEL. Level can be used as hierarchical structure having child nodes like 1 as root then 2 as child then 3. Level have initial value as 1, here Sysdate adds up with Level and act as multilevel structure, then could be helpful to display dates in consecutive manner.
- PLSQL | LOG Function
- PLSQL | INSTR Function
- PLSQL | INSTRB Function
- PLSQL | LENGTH2 Function
- PLSQL | SOUNDEX Function
- PLSQL | ASCII Function
- PLSQL | CONCAT Function
- PLSQL | COMPOSE Function
- PLSQL | CHR Function
- PLSQL | ASCIISTR Function
- PLSQL | CONVERT Function
- PLSQL | DECOMPOSE Function
- PLSQL | DUMP Function
- PLSQL | INITCAP Function
- PLSQL | LENGTHC Function
- PLSQL | LENGTHB Function
- PLSQL | LENGTH4 Function
- PLSQL | LENGTH Function
- PLSQL | LPAD Function
- PLSQL | INSTRC Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.