简体   繁体   English

如何比较 MS Dynamics AX 2009 中的两个日期?

[英]How to compare two dates in MS Dynamics AX 2009?

How to compare two dates (instances of type Date, not utcDateTime) in MS Dynamics AX 2009?如何在 MS Dynamics AX 2009 中比较两个日期(日期类型的实例,而不是 utcDateTime)?

I want to check if particular date, taken from the table, is before (or after) the another one.我想检查从表格中获取的特定日期是否在另一个日期之前(或之后)。 Both are date types.两者都是日期类型。

Is there a way to convert date to utcDateTime datatype?有没有办法将日期转换为 utcDateTime 数据类型?

How to compare two dates?如何比较两个日期?

Use the comparison operators < <= >= > == and != .使用比较运算符< <= >= > ==!=

if (LedgerTrans.TransDate > systemDateGet() - 3)
    LedgerTrans.TransDate = systemDateGet() - 3; 

This works in selects too:这也适用于选择:

select firstonly LedgerTrans 
    where LedgerTrans.TransDate > systemDateGet() - 3;

It works in query input ranges as well: >13-08 will select select dates after August 13'th of the current year.它也适用于查询输入范围: >13-08将 select select 日期在当年 8 月 13 日之后。 See also:http://kashperuk.blogspot.com/2010/02/utcdatetime-in-dynamics-ax-2009.html另见:http://kashperuk.blogspot.com/2010/02/utcdatetime-in-dynamics-ax-2009.html

How to convert a date to utcDateTime ?如何将日期转换为utcDateTime

DateTimeUtil::newDateTime(systemDateGet(), 0, DateTimeUtil::getUserPreferredTimeZone()));

See also: http://msdn.microsoft.com/en-us/library/cc584924.aspx另请参阅: http://msdn.microsoft.com/en-us/library/cc584924.aspx

There is no need to convert Date to utcDateTime to compare two dates.无需将Date转换为utcDateTime即可比较两个日期。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM