Odd date formula...

djswimdjswim Member Posts: 277
Alright all you date formula wizards, here's one for you:

I want a payment to be due on the next 28th of the month. If today is the 1st-27th, the payment is due on the 28th. If today is the 28th-next months 27th, then payment is due on the 28th of next month. Any ideas?
"OMG ALL MY DATA IS GONE"
"Show All..."
"Oh..."

Comments

  • garakgarak Member Posts: 3,263
    edited 2008-10-01
    i understand this correct?

    01.Jan - 27.Jan -> Payment Date -> 28.Jan
    28.Jan - 31.Jan -> Payment Date -> 28.Feb
    01.Feb - 27.Feb -> Payment Date -> 28.Feb
    28.Feb - 28/29.Feb -> Payment Date -> 28.Mar

    Why this? Which customer would pay his order Order (invoice date is 27th) on the next day (28)? Then, i as customer, wait one day, before i order in your firm ;-)
    So, for me, the dateformula is very confuse ....

    Regards
    Do you make it right, it works too!
  • matttraxmatttrax Member Posts: 2,309
    Does it have to be one date formula? If so I'm not sure you can do that.
    Day := DATE2DMY(MyDate, 1);
    Month := DATE2DMY(MyDate, 2);
    Year := DATE2DMY(MyDate, 3);
    IF Day < 27 THEN
      PaymentDate := DMY2DATE(28, Month, Year)
    ELSE
      IF Month = 12 THEN
        PaymentDate := DMY2DATE(28, 1, Year + 1)
      ELSE
        PaymentDate := DMY2DATE(28, Month + 1, Year)
    

    Something close to that I think. If there's a way to do it with a DateFormula I'd be very interested to see it.

    I also agree with Garak, seems like a weird requirement.
  • kinekine Member Posts: 12,562
    -27D+1M-CM+27D
    
    8) :wink:
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Alex_ChowAlex_Chow Member Posts: 5,063
    kine wrote:
    -27D+1M-CM+27D
    
    8) :wink:

    Damn, you beat me to it. :|

    The above formula will do. And I'm assuming you're putting this formula into the recurring journal?
Sign In or Register to comment.