FINANCIAL YEAR CLOSE

人盡茶涼 提交于 2019-12-11 17:53:12

问题


I have a SQL query which was initially this-

DELETE FROM table_1
WHERE column_1 IN (  SELECT column_1 FROM table_2 WHERE 
column_3 < CURRENT - INTERVAL(N) MONTH TO MONTH)

Now my advisory has told to use Financial Close Year instead of CURRENT like:

DELETE FROM table_1
WHERE column_1 IN (  SELECT column_1 FROM table_2 WHERE 
column_3 < FINANCIAL YEAR CLOSE - INTERVAL(N) MONTH TO MONTH)

FINANCIAL YEAR CLOSE being March End.

I have no idea as to how I should incorporate the changes.


回答1:


Since FINANCIAL YEAR CLOSE can be different from one company to another it is not a built in function and has to be calculated manually.

You need to use CURRENT and extract the year part from that date and create a new date from [current year]-03-31 and use that in your query.

Some googling makes me think this is an Informix database from IBM.




回答2:


You could always use TO_DATE() with a specific mask, something like:

$dbaccess stores7 -
Database selected.

> SELECT (TO_DATE("2018-03-01","%Y-%m-%d") - INTERVAL (1) MONTH TO MONTH) FROM TABLE(SET{1});
(constant)
2018-02-01 00:00:00.00000
1 row(s) retrieved.
>
Database closed.
$

Whatever you put as a date string is really up to you ;)



来源:https://stackoverflow.com/questions/49293347/financial-year-close

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!