Date picker in app designer

9 Ansichten (letzte 30 Tage)
Ayabonga Plandeyishi
Ayabonga Plandeyishi am 16 Aug. 2020
Bearbeitet: Mohammad Sami am 22 Aug. 2020
Hi there, I have recently started designing apps with App Designer and I am new to this.
So my app is supposed to handle financial calculation i.e set up amortisation tables for loans etc.
So I have two date pickers one for the start date and the other for the end-date. I have written a function that calculates the duration between two dates using years(d2-d2) but now when I try to display the date on an edit field { app.TermtoDate.Value = app.numberofperiods} I get an error message saying the value must be a double....
here is my code:
function Duration11(app,d1,d2)
start = datestr(d1)
enddate = datestr(d2)
app.numberofperiods = years (enddate-start)
**where numberofperiods is initiated as a property
I called this function under a buton callback

Akzeptierte Antwort

Mohammad Sami
Mohammad Sami am 17 Aug. 2020
You are converting date into string using datestr. You can directly subtract the date time object. years(d2-d1)
  2 Kommentare
Ayabonga Plandeyishi
Ayabonga Plandeyishi am 21 Aug. 2020
Thanks Mohammad, now is there a way to store a date in a list or vector for later use?
Mohammad Sami
Mohammad Sami am 22 Aug. 2020
Bearbeitet: Mohammad Sami am 22 Aug. 2020
Yes you can have arrays of datetime. You can read the documentation for more details.
https://www.mathworks.com/help/matlab/ref/datetime.html

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by