From Date and To date calculation

if(this.fromdate && (this.todate >> this.fromdate))
{
This.reqdays = any2str(this.todate- this.fromdate);
}
Else
{
Throw error (“Todate must be grater than fromdate”);
}

above code is not working
can u plz guide me!!!

Hi Ven Benz,

try this…

static void Job19(Args _args)
{
TransDate fromDate,toDate;
int reqDays;
;

fromDate = mkdate(01,07,2011);
toDate = mkdate(19,07,2011);

if(fromDate && (toDate > fromdate))
{
reqDays = todate - fromDate;
}
else
{
throw error(strfmt(“To-date %1 must be greater than from-date %2”,todate,fromdate));
}
info(strfmt("%1",reqDays));
}

Naresh Kolli

this.RequestedFromTime = timenow();

if(this.RequestedToDate && (this.RequestedToDate >this.RequestedFromDate ))

{

this.RequestedDays = this.RequestedToDate - this.RequestedFromDate;

}

else

{

throw error("To-date must be greater than from-date ");

}

In above code I am first entering this.RequestedFromDate the next step its showing error with out entering RequestedToDate

Hi Ve Benz,

You are giving only the this.RequestedFromTime,but in the if coniditon you are checking for the this.RequestedToTime…so if it is not it obviously shows the error…If this is case you need to give the RequestedToTime also…

If this is not the case, can you can explain it in details…

Naresh Kolli

Where you have placed this code?

i wrote the code in Table level modifiedfield method

now i changed code

if(this.ApprToDate && this.ApprToDate < this.ApprFromDate)

{

throw error(“ApprFromDate Must be greater than ApprFromDate”);

}

if(this.ApprToDate && this.ApprToDate > this.ApprFromDate)

{

this.ApprovedDays = this.ApprToDate - this.ApprFromDate;

}

like this its working now

thanks for replays

thanQ;