Code Sample, a copy-pastable example if possible

data = list(zip([dt.date(2011, 1, 1), dt.date(2007, 1, 1), dt.date(2015, 1, 1)], [1, 1, 1]))
df = pd.DataFrame(data, columns=['date', 'value']).set_index('date')
df.index = pd.to_datetime(df.index)

df['2005':]  # works
df[dt.date(2005, 1, 1):] # fail
df[dt.datetime(2005, 1, 1):] # fail
df[dt.datetime(2005, 1, 1, 0, 0):] # fail
df[pd.Timestamp('20050101'):] # fail

df = df.sort_index()
df['2005':]  # works
df[dt.date(2005, 1, 1):] # works
df[dt.datetime(2005, 1, 1):] # works
df[dt.datetime(2005, 1, 1, 0, 0):] # works
df[pd.Timestamp('20050101'):] # works


Problem description

I am not sure why you could slice by string representation of a date but no the date object. when index is sorted, all call works.

Expected Output

same as sorted

Output of pd.show_versions()

INSTALLED VERSIONS

commit: None python: 3.6.0.final.0 python-bits: 64 OS: Windows OS-release: 7 machine: AMD64 processor: Intel64 Family 6 Model 94 Stepping 3, GenuineIntel byteorder: little LC_ALL: None LANG: None LOCALE: None.None pandas: 0.19.2 nose: 1.3.7 pip: 9.0.1 setuptools: 27.2.0 Cython: 0.25.2 numpy: 1.11.3 scipy: 0.18.1 statsmodels: 0.6.1 xarray: None IPython: 5.1.0 sphinx: 1.5.1 patsy: 0.4.1 dateutil: 2.6.0 pytz: 2016.10 blosc: None bottleneck: 1.2.0 tables: 3.2.2 numexpr: 2.6.1 matplotlib: 2.0.0 openpyxl: 2.4.1 xlrd: 1.0.0 xlwt: 1.2.0 xlsxwriter: 0.9.6 lxml: 3.7.2 bs4: 4.5.3 html5lib: 0.999999999 httplib2: None apiclient: None sqlalchemy: 1.1.5 pymysql: None psycopg2: None jinja2: 2.9.4 boto: 2.45.0 pandas_datareader: None

[paste the output of ``pd.show_versions()`` here below this line]

Comment From: jreback

actually this is not a bug, but see the section in red. I think the docs are pretty clear. http://pandas.pydata.org/pandas-docs/stable/timeseries.html#slice-vs-exact-match

If you disagree, please open a pull-request with edits / examples or whatever you think might help.

Comment From: jreback

if you try using pd.Timestamp('20150101') IOW a point that exists in the range then your slice will work (could also be a datetime.date). For a sorted index you can use a point not in the range and it will still work, but unsorted we can't do this (otherwise we would have to sort it).