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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

End date should be greater than start date

(0) ShareShare
ReportReport
Posted on by 390

Hey team,

I want that my end date should be greater than start date.

this is the code which I had written in validatewrire() method of table but this code also gives the error message even if the end date is greater than start date. Please can you tell me what is wrong with my code?

public boolean validateWrite()
{
boolean ret;
TransformationAssociates trans;
ret = super();
if(trans.EndDate<=trans.StartDate)
{
ret = ret && checkFailed("End Date should be greater then Start Date");
}

return ret;
}

Also Please can you tell me, On the end date calendar how can we disable on all dates on the form before the start date or today's date.

My form has fields: First Name,Last name, Email,StartDate, EndDate

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    239,040 Most Valuable Professional on at

    Please use Insert > Insert Code (in the rich formatting view) to paste source code. It preserves indentation, making code easier to read.

    Like this:

    public boolean validateWrite()
    {
    	boolean ret;
    	TransformationAssociates trans;
    	
    	ret = super();
    	
    	if (trans.EndDate <= trans.StartDate)
    	{
    		ret = ret && checkFailed("End Date should be greater then Start Date");
    	}
    
    	return ret;
    }

    The problem is that you're using trans variable, but you never put any value to it, therefore all fields have their default values. Then you fail the validation if the dates are the same, which will always be the case if both have the default value.

    Use this variable instead (it refers to the object of the instance method).

    public boolean validateWrite()
    {
    	boolean ret = super();
    
    	if (this.EndDate <= this.StartDate)
    	{
    		ret = checkFailed("End Date should be greater then Start Date");
    	}
    
    	return ret;
    }

  • skd Profile Picture
    390 on at

    Hey Martin Dráb,

    Thank you. Also Please can you tell me, On the end date calendar how can we disable  all dates on the form before the start date or today's date.

    My form has fields: First Name,Last name, Email,StartDate, EndDate

  • nmaenpaa Profile Picture
    101,166 Moderator on at

    What do you mean by "Date calendar"?

  • Suggested answer
    Vipin J Profile Picture
    1,603 on at

    Refer here

    How to validate end date to be greater than start date

  • Martin Dráb Profile Picture
    239,040 Most Valuable Professional on at

    Hi Vipin, your code doesn't seem to be related to record validations. It's not even X++.

    I see you started posting more replies just with links to your blog. If their intention is to merely promote your blog and not to answer questions, they'll be deleted as spam.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 663

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 439 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 337 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans