0% found this document useful (0 votes)
4 views

DateFunctions CheatSheet

Uploaded by

chanduvenu
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

DateFunctions CheatSheet

Uploaded by

chanduvenu
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Cheat Sheet: Date Functions

ADD_MONTHS:
Adds the number of months passed in the second parameter to the date passed in the first parameter, and returns the result.

Syntax:
ADD_MONTHS(original_date,number_of_months)

If number_of_months is negative, the function subtracts that number of months from the original_date.

LAST_DAY:
Returns the date of the last day of the month that contains the date passed as parameter.

Syntax:
LAST_DAY(date)

MONTHS_BETWEEN:
Returns the number of months between the first_date and the second_date. It can return decimals if the difference is not an exact
number of months.

Syntax:
MONTHS_BETWEEN(first_date,second_date)

If the first_date is later than the second_date, the result is positive. If the second_date is later the result is negative.

EXTRACT:
Extracts and returns the value of a specified datetime portion from a date or timestamp.

Syntax:
EXTRACT(datetime_portion FROM datetime_expression)

If datetime_expression is a date, datetime_portion can be year, month or day. If it is a timestamp, datetime_portion can be year,
month, day, hour, minute, second, timezone_hour, timezone_minute, timezone_region and timezone_abbr.

NEXT_DAY:
Returns the date of the first weekday named by day_name that is later than the date original_date.

Syntax:
NEXT_DAY(original_date,day_name)

The argument day_name must be a day of the week in the date language of your session, either the full name or the abbreviation.

TRUNC:
Returns the original_date truncated to the unit specified by the format_model.

Syntax:
TRUNC(original_date[,format_model])

The format_model parameter is optional. If it is omitted, the function removes the time portion and returns the original_date with the
time set to midnight.

ROUND:
Returns the original_date rounded to the unit specified by the format_model.

Syntax:
ROUND(original_date[,format_model])

The format_model parameter is optional. If it is omitted the original_date is rounded to the nearest day.

sql.standout-dev.com

You might also like