hougaard / Simple-Object-Designer

Issue tracking for the Simple Object Designer for Business Central
7 stars 0 forks source link

Calculate Days between two date fields #319

Closed ScottB-Ronco closed 8 months ago

ScottB-Ronco commented 8 months ago

Is it possible with the calculated field functionality to create a calculated field that counts days between two date fields?

What we what to do is have a field called Payment Days on the Customer Ledger Entries screen that takes the Closed at Date - Posting Date and give us back total number of days between the two date fields.

I've the expression Rec."Closed at Date" - Rec."Posting Date" and also CalcDate(Rec."Closed at Date",Rec."Posting Date") but whenever I verify the expression I keep getting an error of "Type mismatch (Decimal vs. Date)".

I did make the field type as Decimal so I am assuming this is the reason for type mismatch error.

With that how would I got about created the required field in regards to the field type being used and getting the days between two date fields.

efoqusca commented 8 months ago

This is right Rec."Closed at Date" - Rec."Posting Date"

but the type of the calculated field has to be integer (a number of dates is not a date, is an integer).

ScottB-Ronco commented 8 months ago

OK so I did that, I set the field type to integer and I used the expression Rec."Closed at Date" - Rec."Posting Date" however I still get the error Syntax error: Syntax error: (Line 1): Type mismatch Integer vs Date when I go to verify the expression.

hougaard commented 8 months ago

Ignore that... That might be the Simple Object Designer not realizing date-date=integer - I'll check that...

Try publishing :)

ScottB-Ronco commented 8 months ago

So I published it and it worked as expected.

Seems on the next SOD release you will need to update the expression validator to take the date-date=integer into account as a valid expression.

I'll be closing this issue now.

Thank you again for your quick response.