Mega Code Archive

 
Categories / Oracle PLSQL Tutorial / Date Timestamp Functions
 

Using Datetime Functions

In the following table, x represents a datetime or a timestamp. FunctionDescription ADD_MONTHS(x, y)Add y months to x. If y is negative, y months are subtracted from x. LAST_DAY(x)Get the last day of the month. MONTHS_BETWEEN(x, y)Returns the number of months between x and y. If x appears before y on the calendar, the number returned is positive. NEXT_DAY(x, day)Returns the datetime of the next day following x; day is specified as a literal string, for example SATURDAY. NEW_TIMEReturns the time/day value from a time zone specified by the user. ROUND(x [, unit])Rounds x. By default, x is rounded to the beginning of the nearest day. You may supply an optional unit string to indicate the rounding unit. SYSDATE()Returns the current datetime set for the operating system. TRUNC(x [, unit])Truncates x. By default, x is truncated to the beginning of the day. You may supply an optional unit string that indicates the truncating unit.