Can somebody help me with this ? I need that rows get a different colour if 2 years have passed since inserted Date. But I don't know how to increase my data field by 2 years for this
public void displayOption(Common _record, FormRowDisplayOption _options)
{
dbContacts _dbContacts;;
_dbContacts = _record;
if(_record.(fieldnum(dbContacts,DDataWydania)) == systemDateGet())
// DDataWydania + 2 years > Currentdate
{
_options.backColor(WinAPI::RGB2int(127,255,0));
// _options.colorOnSelectedRow(WinApi::RGB2int(64,128,128));
}
super(_record, _options);
}
You have several options. One of them is using functions preYr() or nextYr(). For example:
public void displayOption(Common _record, FormRowDisplayOption _options)
{
dbContacts dbContacts = _record;
if (dbContacts.DDataWydania > preYr(preYr(systemDateGet())))
{
_options.backColor(WinAPI::RGB2int(127,255,0));
}
super(_record, _options);
}
A more flexible approach is using DateTimeUtil::addYears(), just note that it returns utcDateTime and you need DateTimeUtil::date() to convert it to date data type.
Notice also how I simplified your code - you don’t need fieldnum() if you cast the value to the right type. That will also give you code completion and compile-time checks.