Skip to content

Date difference is giving wrong negative value #421

@maulik-chavda

Description

@maulik-chavda

Hi,

we are using https://www.nuget.org/packages/RulesEngine/ to execute rules

which does use expression.CompileFast(); Reference : https://github.com/microsoft/RulesEngine/blob/main/src/RulesEngine/ExpressionBuilders/RuleExpressionParser.cs#L68

for certain expression of date difference it giving wrong negative values, while expression.Compile() is giving correct result for below expressions

e.g.

(DateTime.Now - Contract.StartDate).TotalDays 
(DateTime.Now.Date - Contract.StartDate.Date).TotalDays 

is giving wrong --10675001 value instead of 198, when DateTime.Now is 2024-07-17T19:09:02.088+05:30 and StartDate is 2024-01-01

while its working fine for below expressions in FastExpressionCompiler

(Contract.StartDate - Contract.StartDate).TotalDays 
(DateTime.Now - DateTime.Now).TotalDays 

Looking for fix or some workaround for this scenario.

Thanks!

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions