Convert scalar values into date time and viceversa
Show older comments
Hello, I want to obtain an estimated date in the future from adding a numerical value (converted into date) plus today's date. In other words, take today's date and sum it to the equivalent date in years, months and days from a scalar result previously obtained.
Any body have an idea. Is it possible?
Thanks in advance.
Anatoly Kurman Rivero
Answers (2)
Star Strider
on 12 May 2019
Edited: Star Strider
on 12 May 2019
One approach:
D = datetime('now');
Future = D + days(1000)
producing:
Future =
datetime
05-Feb-2022 09:13:39
Experiment to get the result you want.
EDIT —
Offset = days(Future - D)
Offset =
1000
Sulaymon Eshkabilov
on 12 May 2019
Hi,
It is possible and here is the command syntax:
DateStr = '12-May-2019';
FormatIn = 'dd-mmm-yyyy';
Today = datenum(DateStr,FormatIn)
DateNumber = Today+1;
FormatOut = 'mmmm-dd-yyyy';
str = datestr(DateNumber,FormatOut,'local')
vice-versa:
Good luck.
Categories
Find more on Calendar 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!