web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Split Date Between From and To date in AX 2012 X++ code

(0) ShareShare
ReportReport
Posted on by 5,680

Hi All,

I have created Dialog with Two fields:

From Date : 01/01/2014 -- given Jan

To Date     : 31/03/2014 --- given march

after given from and to date in dialog field and click ok button in dialog.

when closing dialog with filled from and to date above given I need to display date in info in the below format:

info - 31/01/2014 ----last date of month in jan

info - 28/22014 ----last date of month in Feb

info - 31/03/2014----last date of month in march

the above I explained how to split date from two different date withdate display last date of month.........

plz let me know any one face about this..........

 

Thanks in Advance,

A.D.KARTHIK

 

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    ArunGarg Profile Picture
    3,926 on at
  • Verified answer
    Abhimanyu Naruka Profile Picture
    160 on at

    Hi Karthik

    To get last dates of month you may use "static date dateEndMth(date transDate)".

    Can provide some more example to explain your split date problem

  • Verified answer
    jasman Profile Picture
    1,413 on at

       date dfrom    = 01\01\2014;

       date dto      = 31\03\2014;

       date dcalc;

       date lastDayInJan;

       date lastDayInFeb;

       date lastDayInMar;

       dcalc = mkDate(1,mthOfYr(dfrom),year(dfrom));   // 1st date of chosen mth/yr

       dcalc = nextMth(dcalc);

       lastDayInJan = dcalc - 1;  // Last day in month (january)

       dcalc = nextMth(dcalc);

       lastDayInFeb = dcalc - 1;  // Last day in month (february)

       dcalc = nextMth(dcalc);

       lastDayInMar = dcalc - 1;

       info("Last date in january: "+queryValue(lastDayInJan)+"\nlast date in february: "+queryValue(lastDayInFeb)+"\nlast date in march: "+queryValue(lastDayInMar));

  • Verified answer
    Jonathan  Halland Profile Picture
    11,310 on at
    date tmpEnd = endMth(startdate);
        
        do
        {
            info(strFmt("%1", tmpEnd));
            tmpEnd  = endmth(nextMth(tmpEnd));
        } while (tmpEnd <= endmth(endDate));

    OR

    date tmpEnd = endMth(startdate);
        
        do
        {
            info(strFmt("%1", tmpEnd));
            tmpEnd  = endmth(nextMth(tmpEnd));
        } while (tmpEnd <= endDate);


  • jasman Profile Picture
    1,413 on at

    I was quite old school there (remnants of my XAL coding days).

    Of course the endmth intrisic function is the way to go. :)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans