Skip to content

Instantly share code, notes, and snippets.

@guerbai
Created June 2, 2019 05:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guerbai/35d7923dc04aca14288c340ed3260943 to your computer and use it in GitHub Desktop.
Save guerbai/35d7923dc04aca14288c340ed3260943 to your computer and use it in GitHub Desktop.
python根据时间搜索mongo记录
if getattr(request, 'start_date'):
start_date = datetime.datetime.strptime(request.start_date, '%Y-%m-%d')
search_dict['applicant_time__gte'] = start_date
if getattr(request, 'end_date'):
end_date = datetime.datetime.strptime(request.end_date, '%Y-%m-%d') + datetime.timedelta(days=1)
search_dict['applicant_time__lte'] = end_date
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment