Datetime 多个UTC日期时间比较

Datetime 多个UTC日期时间比较,datetime,compare,axapta,dynamics-ax-2012,dynamics-ax-2012-r2,Datetime,Compare,Axapta,Dynamics Ax 2012,Dynamics Ax 2012 R2,我的表格中有以下记录: 2015年11月11日04:48:05下午 2015年11月11日04:50:58下午 2015年11月11日05:07:17下午 2015年11月11日下午5:08:32 当我使用DateTimeUtil::getSystemDateTime;-今天的时间 我需要将其他记录与今天的时间进行比较,以找到最接近当前日期时间的记录 我正在考虑使用DateTimeUtil::getDifference,但当有两个以上的UTC dateTime时,我无法使逻辑正确。忘记比较日期,

我的表格中有以下记录:

2015年11月11日04:48:05下午 2015年11月11日04:50:58下午 2015年11月11日05:07:17下午 2015年11月11日下午5:08:32

当我使用DateTimeUtil::getSystemDateTime;-今天的时间

我需要将其他记录与今天的时间进行比较,以找到最接近当前日期时间的记录


我正在考虑使用DateTimeUtil::getDifference,但当有两个以上的UTC dateTime时,我无法使逻辑正确。

忘记比较日期,只需按日期/时间降序排序记录

select firstonly custTrans order CreatedDateTime desc;
这将选择最接近现在的记录,前提是有人没有将时钟拨到未来。

我成功地使用了这一逻辑,谢谢。
你能告诉我们你到目前为止写的代码,以及你不能使逻辑正确的部分吗?还有一个可能的副本
str                lastUser;
utcDateTime        highest = DateTimeUtil::minValue();

ttsBegin;
while select ItemId, CreatedDate, User  from this
    where this.ItemId == _itemId // && this.ProductType == Options::Changed
    {
      //  info(strFmt("CurrentDate: %2", this.ItemId, this.CreatedDate));
    /*    if(this.CreatedDate < loweste)
        {
            loweste = this.CreatedDate;
        } */
         if(this.CreatedDate > highest)
        {
            highest = this.CreatedDate;
            lastUser = this.User;
        }
     //   info(strFmt("lowest is: %1" , loweste));
     //   info(strFmt("highest is: %1 ", highest));
   /*     if(loweste < highest)
        info(strFmt("highest is: %1" , loweste));
     */
    }