In Oracle, TRUNC(datetime, unit) function allows you to truncate a datetime value to the specified unit (set zero time, set the first day of the month i.e).
Oracle:
-- Get current datetime with the time set to zero (returns: 2012-07-13 00:00:00) SELECT TRUNC(SYSDATE) FROM dual;
Oracle TRUNC for datetime:
Syntax | TRUNC(datetime [, unit]) |
Default Unit | 'DD' truncates to day (sets zero time) |
TRUNC function supports the following truncation units (full list...):
Oracle TRUNC Unit | Truncation | Result | |
'DD' | 'DDD' | Day | YYYY-MM-DD 00:00:00 |
'MM' | 'MONTH' | Month | YYYY-MM-01 00:00:00 |
'YY' | 'YEAR' | Year | YYYY-01-01 00:00:00 |
'HH' | 'HH24' | Hour | YYYY-MM-DD HH:00:00 |
'MI' | Minute | YYYY-MM-DD HH:MI:00 |
SQLines offers services to migrate Oracle databases and applications to Microsoft SQL Server. For more information, please Contact Us.