python time range monthly

Solutions on MaxInterview for python time range monthly by the best coders in the world

showing results for - "python time range monthly"
Mathilda
29 Oct 2020
1>>> from datetime import datetime, timedelta
2>>> from collections import OrderedDict
3>>> dates = ["2014-10-10", "2016-01-07"]
4>>> start, end = [datetime.strptime(_, "%Y-%m-%d") for _ in dates]
5>>> OrderedDict(((start + timedelta(_)).strftime(r"%b-%y"), None) for _ in xrange((end - start).days)).keys()
6['Oct-14', 'Nov-14', 'Dec-14', 'Jan-15', 'Feb-15', 'Mar-15', 'Apr-15', 'May-15', 'Jun-15', 'Jul-15', 'Aug-15', 'Sep-15', 'Oct-15', 'Nov-15', 'Dec-15', 'Jan-16']
7