how to extract previous week and month number of same hour?
Show older comments
I had load data of one year, half houly data of load (1*17520), I want to add a column having load data of previous week (same day & time period) and another column having previous day data at same time slot
We can keep blank for initial week/day data because for that previous data is not available here.
5 Comments
KSSV
on 16 Jun 2020
You split the date availables into days, months, years, hours, minutues, seconds using datevec. You can use indexing of months and time you want and get the value you want.
MUKESH KUMAR
on 16 Jun 2020
KALYAN ACHARJYA
on 16 Jun 2020
You can do it in multiple ways, it would be better to clear, if you can attach one same file
MUKESH KUMAR
on 16 Jun 2020
Steven Lord
on 17 Jun 2020
KSSV: if MUKESH KUMAR has the date and time data stored as a datetime array or as the time vector in a timetable, there's no need to split that data to jump backwards a day or a week.
d = datetime('now')
dMinusWeek = d - calweeks(1)
dMinusDay = d - caldays(1)
Accepted Answer
More Answers (0)
Categories
Find more on Spreadsheets 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!