Server Date

After creating Fixed asset depreciation journal, when we use to create lines items,the transaction date will take ““today”” date as customized

But as if now it is taking client machine date and not taking as server date. My code is as below in table LedgerJournalTrans

method “validate field”.

case fieldnum(LedgerJournalTrans, transdate):

if (this.TransDate)

{

changecompany(this.Company)

{

select ledgerjournalname where ledgerjournalname.JournalName==LedgerJournalTable::find(this.JournalNum).JournalName;

if(!ledgerjournalname.Cu_FADJournal && this.TransDate<systemdateget())

{

if((systemdateget()-this.TransDate)>ledgerjournalname.Cu_NoofDaysforBackdated)

ret=checkfailed(strfmt(“Backdated entries will be allowed upto %1 Days only”,ledgerjournalname.Cu_NoofDaysforBackdated));

}

if(this.TransDate>systemdateget())

{

ret=checkfailed(“Future date shouldnot be selected”);

}

}

}

How to take the server date…Please help???

Because user can change the client date and can able to pass backdated entries.

System.DateTime::get_Now();

http://www.axaptapedia.com/Current_Time

This is not working

if(this.TransDate <System.DateTime::get_Now()) ---------------->Throwing error “Operand types are not compatible with operater”.

Because LedgerJournalTrans.TransDate is having only date and no time is there…Any other solutions???

Hi,

This was already discussed here. I did a quick search and found this - http://dynamicsuser.net/forums/p/40560/207854.aspx#207854

For just date part, try this -


transDate dt;
;

dt = DateTimeUtil::date(DateTimeUtil::applyTimeZoneOffset(DateTimeUtil::getSystemDateTime(), DateTimeUtil::getUserPreferredTimeZone()));
info(strfmt(’%1’, dt));