It's a bit puzzling that you are aware of timetables and yet resort to deprecated functions such as histc (which has no concept of dates) for the rest of your code, instead of using timetables functions which would make your task trivially easy.
Even the way you construct your timetable is more complicated than it should:
DT = array2timetable(Data1, 'VariableNames', {'Price', 'Demand'}, 'RowTimes', datetime(2006, 1, 1):dateime(2018, 12, 31));
There is no point in storing Ye, M, D separately. It's already stored as part of the time.
Once you have a timetable, you can easily resample it at regular or irregular intervals using retime. However retime doesn't do
meanDT = retime(DT, 'regular', 'mean', 'TimeStep', caldays(14));
stdDT = retime(DT, 'regular', @std, 'TimeStep', caldays(14));
meanDT.Properties.VariableNames = {'MeanPrice', 'MeanDemand'};
stdDT.Properties.VariableNames = {'StdPrice', 'StdDemand'};
meanstdDT = [meanDT, stdDT]
Instead of using two retime, you could use groupsummary instead: meanstdDT = groupsummary(DT, 'Time', caldays(14), {'mean', 'std'})
Now you say you want 4 bins per month. What does that mean exactly. 4 equal bins per month means that the edges fall at odd times during the days instead of falling at the end of days. That doesn't sound like something you'd want. In the above, I've used bins of 14 days but both retime and groupsummary support a bin vector instead. To construct a bin vector with 4 equal bins per month, the simplest is probably:
monthvector = DT.Time(1) : calmonths(1) : DT.Time(end) + calmonths(1);
binvector = fillmissing(reshape([monthvector; NaT(3, numel(monthvector))], [], 1), 'linear')
and then
meanstd = groupsummary(DT, 'Time', binvector, {'mean', 'std'})
Best Answer