Table of Contents
Ispirer Website
Ispirer Capabilities - Oracle Migration
Free Trial
Oracle - Date and Time Functions
This article describes the date and time functions in Oracle.
Overview
Date and Time Function | Description |
---|---|
SYSDATE | Returns the current date and time |
TRUNC(Date) | Truncates date to the specified part |
SYSDATE
Oracle - SYSDATE | |
---|---|
Syntax | SYSDATE |
Parameter | The function requires no arguments. |
Description | Returns the current date and time set for the operating system on which the database resides. |
Return Type | The datatype of the returned value is DATE, and the format returned depends on the value of the NLS_DATE_FORMAT initialization parameter. |
Notice | You cannot use this function in the condition of a CHECK constraint. |
Equivalents in Other Databases
Database | Equivalent |
---|---|
SQL Server | GETDATE - Returns the current system date and time. |
TRUNC(Date)
Oracle - TRUNC(Date) | |
---|---|
Syntax | TRUNC(date [, format]) |
Description | Truncates date to the part specified by format (DD - day, MM - month, YYYY - year, HH - hour, MI - minute). See Oracle SQL Reference for the full list of truncation options |
Default | format is DD (day), truncation to year, month and day |
Return Value | Return type is DATE |
Example:
- Return all orders placed today
SELECT * FROM orders WHERE TRUNC(r_created)=TRUNC(SYSDATE);
Oracle TRUNC(Date) - Equivalents in Other Databases
Database | Equivalent |
---|---|
MySQL | DATE(date) - returns date (year, month, day) |