Date: prev next · Thread: first prev next last
2018 Archives by date, by thread · List index

2018-01-28 17:01 GMT+01:00 Luuk <>:

On 28-01-18 16:30, Johnny Rosenberg wrote:
2018-01-28 15:45 GMT+01:00 Luuk <

    You can write a FUNCTION to get next month

    Function FirstOfNextMonth(dDate as Date) as Date
        if Month(dDate)>=12 then
            FirstOfNextMonth = DateSerial(Year(dDate)+1, 1, 1)
            FirstOfNextMonth = DateSerial(Year(dDate), Month(dDate)+1, 1)
        end if
    End Function

    When you use = FirstOfNextMonth(Now()) is will return 01-02-2018  (if
    your date-format = DD-MM-YYYY)

Just note that your function always returns the first day of the
calculated month. I'm not sure the OP wants that, but maybe I'm wrong.

It's named 'FirstOfNextMonth()'with a reason! ;)
Also note that this 'example' function can be adapted to return another
date (whatever the OP wants).

To return 'NextMonth()' next question should be solved:
What is next month, if current date is 31 januari?

Yes, I asked that, kind of, but if I got an answer I missed it. My
suggestion was EDATE(SomeDate,1) which returns the same day of the
nextmonth, following your ”a” suggestion below.
I didn't say your suggestion was wrong, I was just wondering if it was what
the OP asked for. Maybe it was, maybe it wasn't. Maybe he will write back
and tell us. :)

Kind regards

Johnny Rosenberg

a) 28 februari, of 29 februari, depending on the year being a leap year
or not
b) 3 march 2018, (31 days after 31 januari)
c) something else.....

The same question for 31 march, and other months which have a NextMonth
with less days than the current month.

To unsubscribe e-mail to:
Posting guidelines + more:
List archive:
All messages sent to this list will be publicly archived and cannot be

To unsubscribe e-mail to:
Posting guidelines + more:
List archive:
All messages sent to this list will be publicly archived and cannot be deleted


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.