Getting the Current Date and Time
Use the CURRENT_DATE, CURRENT_TIME, and CURRENT_TIMESTAMP functions to get the current date and time from the system clock of the particular computer where the DBMS is running.
To get the current date and time:
- To get the current date, type:
To get the current time, type:
To get the current time stamp, type:
CURRENT_DATE returns a DATE, CURRENT_TIME returns a TIME, and CURRENT_TIMESTAMP returns a TIMESTAMP; see “Datetime Types” in Chapter 3 (Listings 5.25 and 5.26, Figures 5.25 and 5.26).
Listing 5.25. Print the current date, time, and time stamp. See Figure 5.25 for the result.
CURRENT_DATE AS "Date",
CURRENT_TIME AS "Time",