0
我有一個代碼:獅身人面像搜索如何搜索上面的某個日期
def set_date_range_filter(self,attribute = None,start_date = None , end_date = None):
if attribute is None:
return
#Make sure set the passing start date and end date
if not start_date or not end_date :
return
if isinstance(start_date, str) :
start_date = datetime.strptime(start_date, "%Y-%m-%d")
if isinstance(start_date, unicode) :
start_date = datetime.strptime(str(start_date), "%Y-%m-%d")
if isinstance(end_date ,str):
end_date = datetime.strptime(end_date, "%Y-%m-%d")
if isinstance(end_date ,unicode):
end_date = datetime.strptime(str(end_date), "%Y-%m-%d")
# Shphnx Range Filter ,start_date and end_date must be integers that define the acceptable attribute values range
start_date = int(time.mktime(start_date.timetuple()))
end_date = int(time.mktime(end_date.timetuple()))
if start_date > end_date :
return
self.sphinx.SetFilterRange(str(attribute),start_date,end_date)
我要更新這個代碼只接受「起始日期」或只「END_DATE」或兩者兼而有之。
喜歡我想要的所有日期從2014-01-01或我想要的所有數據2014-01-01 之後或說我想要從2014-01-01到2014-09-01的所有數據。我如何存檔這?