How do I chage the format of an input data
2 views (last 30 days)
Show older comments
I have a struct and when i add a new patient i ask the date of birthday
DemographicData(new_patient).Birthday=input('Birthday');
I want matlab to return the date in this format: 12-Dec-1998 for example
0 Comments
Answers (1)
Cris LaPierre
on 29 Dec 2021
Save the birthdates as datetimes. See this page for more. You can then set the display format so that it displays how you'd like.
DemographicData(1).Birthday=datetime('12/12/98','InputFormat','MM/dd/yy')
DemographicData.Birthday.Format = 'dd-MMM-yyyy'
The challenge will be that, with input, you have no control over how the user enters the date, so you can't make any assumptions on what the input format is.
0 Comments
See Also
Categories
Find more on Dates and Time in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!