Date functions

sunctsunct Member Posts: 72
Hello,

I am having a requirement... if you enter any date in the system, the last date of that month should be populated automatically..

any one can help?

Thxs and regds
Regards,
Sunil

Comments

  • garakgarak Member Posts: 3,263
    take a look to the systemfunction: (System -> Date -> Calcdate

    NewDate := CALCDATE(DateExpression [, Date])

    This function (and an help for this) you can find when using C/AL Symbol Menu (F5 in designmode) and press then F1

    Regards
    Do you make it right, it works too!
  • JedrzejTJedrzejT Member Posts: 267
    I do it by this function

    LastMonthDayOfDate(pDate : Date) : Date

    DateRec.SETRANGE(DateRec."Period Type",DateRec."Period Type"::Month);
    DateRec.SETRANGE(DateRec."Period Start",DMY2DATE(1,
    DATE2DMY(pDate,2),
    DATE2DMY(pDate,3)));
    DateRec.FIND('-');

    EXIT(NORMALDATE(DateRec."Period End"));
  • sunctsunct Member Posts: 72
    Thanx a lot ... It helped me!

    Regds
    Regards,
    Sunil
  • garakgarak Member Posts: 3,263
    use Calcdate. You need no new function :!:

    EndDateMonth := calcdate('<CM>',today)
    Do you make it right, it works too!
  • DenSterDenSter Member Posts: 8,305
    So jujst to elaborate a little:
    • "CM" gets you the last day of the month of the date that you passed into CALCDATE.
    • "-CM" gets you the first day of the month of the date that you pass into CALCDATE
    • the "<" and ">" around the dateformula is to make the system language independent
  • JedrzejTJedrzejT Member Posts: 267
    Hi,

    Good to know. I use calcdate only to plus or minus some period to date. Good to read help sometimes. ](*,)

    Regards.
  • garakgarak Member Posts: 3,263
    jupp, sometimes, the "Help" will help :whistle:
    Do you make it right, it works too!
  • DenSterDenSter Member Posts: 8,305
    Also, the first stop for syntax should be the C/SIDE reference guide, from the help menu. It has an excellent search function.
  • garakgarak Member Posts: 3,263
    thats right. Every person, who is new (or old) on NAV, should be use the help (F1) after this, search the forum, there are many questions and answers, or tell us your question. But first: Use help and your brain. [-o<

    These are no angry words 8)

    So, good night
    Do you make it right, it works too!
Sign In or Register to comment.