If we want to create a list of dates such as [19930601, 19930701, ..., 20160701, 20160801], where for each year we have the first day of each month, the following code snippet will create such a list

Step-by-step guide

If we want to create a list of dates such as [19930601, 19930701, ..., 20160701, 20160801], where for each year we have the first day of the same months, the following code snippet will create such a list:




d1 = 1993-06-01
d2 = 2016-08-01
d = d1
datelist = []
while d <= d2 do
    datelist = datelist & [d]
    d = addmonths(d, 12)
end while
print(datelist)




import metview as mv
from datetime import datetime

d1 = datetime(1993,6,1)
d2 = datetime(2016,8,1)
d = d1
datelist = []
while d <= d2:
    datelist.append(d)
    d = mv.addmonths(d, 1)

print(datelist)




Related articles

Related articles appear here based on the labels you select. Click to edit the macro and add or change labels.