How Do I Have my Program Accept a Negative Year as Valid

I am creating a time calculator game to learn how to code and am running into trouble when I input a negative year. How can I program a time calculator that recognizes this negative year as BCE while not displaying an invalid message? I

回答 (1 件)

Alexander
Alexander 2024 年 2 月 16 日

0 投票

datetime(-1,1,1) answeres 01-Jan--0001 which is correct.

2 件のコメント

CHRISTY
CHRISTY 2024 年 2 月 16 日
Thank you, how would I do this for the MM/DD/YYYY format where the user enteres their date like this?
datetime('01/01/-0001', 'inputformat', 'MM/dd/uuuu')
ans = datetime
01-Jan--0001

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

カテゴリ

ヘルプ センター および File ExchangeVideo games についてさらに検索

製品

タグ

質問済み:

2024 年 2 月 16 日

コメント済み:

2024 年 2 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by