Days Difference

alien251alien251 Member Posts: 80
Hello,

I want to add a flowfield that shows the number of days between two dates, how can I do this?

Thanks,

Dan

Comments

  • kapamaroukapamarou Member Posts: 1,152
    Why a flowfield?

    You just need a variable. Is it for a report? A form? Do you want this value stored at a table?
  • DenSterDenSter Member Posts: 8,304
    You can't do that in a flowfield.
  • matttraxmatttrax Member Posts: 2,309
    FlowFields are designed for sums, lookups, averages, etc. The real basics.

    You should add a new field, and then update it when one of the date fields is changed. You can add code to the OnValidate trigger for both.
  • Alex_ChowAlex_Chow Member Posts: 5,063
    You can display the dates dynamically if you put the code on the form as well.
  • DenSterDenSter Member Posts: 8,304
    I would never put this code on the form. I would probably create a function in the table that returns the number of days as an integer based on two date fields in that table, and have a textbox on the form with the function as its sourceexpr.
  • alien251alien251 Member Posts: 80
    I appreciate all of the input! :D

    Doesn't have to be a FlowField but the dates on the table that will be used in the calculation will be flow fields. It's for display only, my finance people will be exporting the data into Excel and running the data through some forecasting tools. The calculation needs to be performed from the Production Order List. I've already added a flow field that looks up the original order date from the sales order archive (since the SO doesn't exist anymore after invoicing, does this pain anyone else?). The forecasting formula needs to know the number of days between the order date and the finished date. Is there something similar to the sql DATEDIFF in Navision that I can use to seed the variable I'll display in the list?

    I looked through Chapter 17: Using Intrinsic C/AL Functions and searched the forum here...

    Ideas...???

    Thanks!!

    Dan
  • DenSterDenSter Member Posts: 8,304
    DateOne - DateTwo = Integer;
    
    With these things you have to try some things. What I always do is put a test form together, in every project I work on I have these test forms with little code snippets to try out different types of calculations, to see what happens with the code. Put some textboxes on it with date variables as sourceexpr. Put a button on there and write some C/AL code in the OnPush event that calculates the difference between the two, and puts the results in a message. Read what the error messages tell you.
Sign In or Register to comment.