Get the App
SLTechnology News&Howtos  ›  Database  › 

Summary of add_months () function and its usage in oracle

Shulou Source: shulou.com Published: 2022-06-01 03:01:35 09月30日 Update

Today, let's briefly summarize the add_months function:

The add_months function mainly operates on the date function and increases the date month by month in the process of data query, in the form of:

Add_months (date,int); where the first parameter is the date and the second is the monthly increase, for example:

Add_months (sysdate,2): this is the time two months after the current date.

For example, it indicates the time after 2 months:

SQL > select add_months (sysdate,2) from dual; ADD_MONTHS (SYSDATE,+2)-2012-5-16 02:30:47

For the time 2 months ago, you can use the following statement

SQL > select add_months (sysdate,-2) from dual;ADD_MONTHS (SYSDATE,-2)-2011-11-16 02:32:39

If the first parameter, the current date, is a specified specific date, then the date needs to be converted using to_date ('20190101 recording journal yyyymmdd`), as follows:

Select * from tb_user where create_date_time > to_date ('20190101') and create_date_timeadd_months (time,2*12)

Summary

The above is the summary of the add_months () function and usage in oracle introduced by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply you in time. Thank you very much for your support to the website!

If you think this article is helpful to you, you are welcome to reprint it, please indicate the source, thank you!

Tags: Date time function query company parameter employee data statement help two between provenance place name that is range year ago form data query Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Microsoft Huawei Docker Shulou Information