I've been playing around with the DateOffsetByComponents() function to implement one of our business requirements. However, the function seems to be returning incorrect values. Either that or my understanding is wrong.
I have a theory about what this function is doing. Having pondered this theory, I am forced to wonder how they could have done it any other way.
The problem is that not every month has 31 days.
It seems (from other tests such as DateOffsetByComponents("2013-03-31", 0, 1, 0), which returns "2013-05-01") that it calculates forward by the month day number in the source date from the first of the month calculated by the month offset figure.
So, in the original post, the calculation is 31 days forward from "2013-02-01", which is "2013-03-03".
How would YOU specify the function's behaviour? What do you believe the function should return from the original example?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
I expected it to return a date that would ideally be in the month of february. I find it difficult to comprehend the rationale behind why the function would be designed to work the way you think it actually is.
Jerome
Data Integration Consultant at AWS
Connect With Me On LinkedIn
Life is really simple, but we insist on making it complicated.
I would want it to take me to the last day of the last month. ie. If my business date is 2013-03-31, then the output should be 2013-02-28. If 2013-03-30, then 2013-02-27.
Jerome
Data Integration Consultant at AWS
Connect With Me On LinkedIn
Life is really simple, but we insist on making it complicated.
So what if it's 2013-02-28? Do you want it to take you to the last day of the previous month (2013-01-31) or the corresponding day number (2013-01-28)? Now do you see the dilemma?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
It should perhaps be subtracting the number of days in the month the specified date is in. So if the date is May 20, it should subtract 31 days and if the date is June 12, then it should subtract 30 days. If the date is in February, it should subtract 28/29 days depending on the year of date.Your thoughts?
Jerome
Data Integration Consultant at AWS
Connect With Me On LinkedIn
Life is really simple, but we insist on making it complicated.