validation for UTC date time

in a form i have 2 fields in a grid 1. Start date time and 2. End date time

Start date time End date time

say when some one enters startdatetime as 14 march 2015 and end date time as 18 march 2015

and next time when they enters strat date time as 15 march 2015 then it should throw a error message any idea how to compare this two date time fields and check all the exsiting vaulues in it.

Thanks,

Rohit

basically it should throw throw error message as 15 march 2015 is already there between 14 march 2015 and 18 march 2015

It’s not clear what problem you have with comparing fields.

Unfortunately you didn’t add a tag with your version of AX; if you use AX 2012, you can do it without any code (see Valid Time State Tables and Date Effective Data).

public boolean validateWrite()

{

boolean ret;

TestValidation TestValidation;

utcDateTime startdatetime1,enddatetime1;

ret = super();

//super(_fieldId);

if(this.Startdatetime)

{

startdatetime1 = this.Startdatetime;

while select Startdatetime from TestValidation

{

info(“1”);

}

while select Startdatetime from TestValidation where TestValidation.Startdatetime <= startdatetime1

&& TestValidation.Enddatetime >= startdatetime1

{

throw error(“entered start date falls between the previous records”);

}

if(this.Enddatetime)

{

enddatetime1 = this.Enddatetime;

while select Enddatetime from TestValidation

{

info(“1”);

}

while select Enddatetime from TestValidation where TestValidation.Startdatetime <= enddatetime1

&& TestValidation.Enddatetime >= enddatetime1

{

throw error("entered end date falls between the previous records ");

}

}

}

return ret;

}