I have a report we have been using for quite some time for total inventory as of a specific date. However, I need to add a column that shows how many days this material has been in inventory. How do I accomplish this?
Let's say my query is:
MVT.INVT_LEV1,
MVT.INVT_LEV2,
MVT.INVT_LEV3,
MVT.INVT_LEV4,
INVT_ORG_RECD_DATE
FROM M_INVT
INVT_ORG_RECD_DATE provides the date the material was received into our inventory. Let's say the data is 07/05/22. I want another column that says inventory has been with us for two days. How do I accomplish this? If this doesn't make sense I can copy over my entire query.
I would imagine the first date is the date in that column, and the second date would be the date I am running the report for? and some how need to system to figure out how many days in between?
The simplest option is to do the calculation within the query:
Why
TRUNC? Becausesysdatereturns both date and time, so you'd get fractional number of days:Another option is to create a formula column in the Data Model Editor (click the appropriate button in the left-hand side toolbar and add it into the group that contains other fields). Name it e.g.
CF_NUMBER_OF_DAYSand edit its properties; code you'd use would beas formula column represents a function that returns some value (a number, in your case).
Finally, add the new field into the Paper Layout Editor. I guess you know how to do that.