Description: It was reported on the German M-L that the help is incorrect when describing how to enter the string for the date. Indeed, it does seem wrong, or rather incomplete, but that is tangential to what is to follow: 1) Open a Writer document 2) Create a new macro module in the document with the following : Sub example_dateadd MsgBox DateAdd("m", 1, 31012004) &" - "& DateAdd("M", 1, 31012005) End Sub Try and execute the macro. Using the above: - if use double quote characters around the date string, I get various error messages, such as "unsuported type", or "unsupported operation" depending on which way I type the string separators (dots or slashes); - if I use as in the above example, i.e. no quotes around what is essentially an integer, I get a MsgBox that displays "31/01/32767 - 31/01/32767" which is obviously incorrect. This latter behaviour is the one being reported here. Steps to Reproduce: See above description Actual Results: See above Expected Results: Correct display of the year. Reproducible: Always User Profile Reset: No Additional Info: User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:57.0) Gecko/20100101 Firefox/57.0
First, DateAdd() expects a Date or date serial number, so what you pass as integer is the number of days since the null-date (1899-12-30). Nevertheless the calculation seems wrong. Investigating.
Eike Rathke committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=db080dad6c9ad9930e26aeb70638d7146afa279a tdf#114011 limit/truncate date, not only year It will be available in 6.0.0. The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
DateAdd() not accepting a (locale dependent) string ("01/31/2004" or "31.01.2004" or always ISO "2004-01-31") IMHO is also wrong.
Actually it does accept the string, but adding one month to 2004-01-31 does not work, apparently because it would result in 2004-02-31 that is not a valid date. Not sure what is expected there, truncate to 2004-02-29? Would need to compare with VBA. Let's mark this fixed for the original problem.
Eike Rathke committed a patch related to this issue. It has been pushed to "libreoffice-5-4": http://cgit.freedesktop.org/libreoffice/core/commit/?id=8be272b6642611e152ddc8e13f8570d2e673e0b4&h=libreoffice-5-4 tdf#114011 limit/truncate date, not only year It will be available in 5.4.4. The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Xisco Fauli committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/c3fc5aaa654b649be9adec8904f76272cd50bb16 tdf#114011: basic_macros: Add unittest It will be available in 7.3.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.