フィルターのクリア

How to display Date as output in Appdesigner?

9 ビュー (過去 30 日間)
Raja Suriyan
Raja Suriyan 2022 年 4 月 5 日
コメント済み: Raja Suriyan 2022 年 4 月 5 日
Hi I am trying to find the earliest start date and the latest finish date for activities.
I have received inputs from user and stored it in an excel file.
Now how to find the earliest start date and the latest finish date and also display it to the user. Also calculate the total cost ie. sum of variable values when the update button is pushed.
% Button pushed function: SaveButton_2
function SaveButton_2Pushed(app, event)
n = app.EnterTotalNoofActivitiesEditField.Value;
% Create table array
sz = [n 4];
varTypes = {'string','datetime','datetime','single'};
varNames = {'Activity','Start Date','End Date','Planned Value'};
t = table('Size',sz,'VariableTypes',varTypes,'VariableNames',varNames);
% Create table UI component
uit = uitable(app.UIFigure);
uit.Data = t;
uit.ColumnEditable = true;
uit.Position(3) = 310;
end
% Button pushed function: RollupButton
function RollupButtonPushed(app, event)
uit = findobj(app.UIFigure,'Type','uitable');
sheet = 'Budget';
writetable(uit.Data,'EVM.xls','Sheet',sheet);
end
% Button pushed function: ExporttoExcelButton_2
function ExporttoExcelButton_2Pushed(app, event)
winopen('EVM.xls');
end
% Button pushed function: UpdateButton
function UpdateButtonPushed(app, event)
end

回答 (1 件)

Walter Roberson
Walter Roberson 2022 年 4 月 5 日
If you are using datetime() objects, then min() and max() are available for those.
You can set the Format property of a datetime object and then string() the object to get text.
  3 件のコメント
Walter Roberson
Walter Roberson 2022 年 4 月 5 日
The first output of xlsread() is never a datetime object. It might be a serial date number, but datetime() applied to serial date numbers requires a "convertfrom" option.
You should consider switching to readtable()
Raja Suriyan
Raja Suriyan 2022 年 4 月 5 日
I tried read table also...read table is not reading datetime I guess.
Any way to rectify it?
Error: Error using min
Invalid data type. First argument must be numeric or logical.
% Button pushed function: Button
function ButtonPushed(app, event)
c=readtable('EVM.xls','Sheet','Budget','Range','B2');
c=min(c);
c=string(c);
app.DateEditField.Value=c;
end
end

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeInstall Products についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by