Sql server 按日期最小值和日期最大值筛选行?
在没有型号的情况下,如何按日期最小值和日期最大值获取过滤器?我连接到外部数据库并获得咨询,但无法过滤 views.pySql server 按日期最小值和日期最大值筛选行?,sql-server,django,Sql Server,Django,在没有型号的情况下,如何按日期最小值和日期最大值获取过滤器?我连接到外部数据库并获得咨询,但无法过滤 views.py def BootstrapFilterView(request): cursor.execute("[Prueba].[dbo].[Pr_Ne] '10/04/2021 4:00:00', '28/05/2021 23:59:59'") qs = cursor.fetchall() prog_data_ini = re
def BootstrapFilterView(request):
cursor.execute("[Prueba].[dbo].[Pr_Ne] '10/04/2021 4:00:00', '28/05/2021 23:59:59'")
qs = cursor.fetchall()
prog_data_ini = request.GET.get('prog_data_ini')
date_min = request.GET.get('date_min', None)
date_max = request.GET.get('date_max', None)
fecha = datetime.now()
format_min = fecha.strftime('%Y-%m-%d')
date_max = fecha + timedelta(days=1)
format_max = date_max.strftime('%Y-%m-%d')
if is_valid_queryparam(date_min):
qs = qs.filter(prog_data_ini__gte=date_min)
if is_valid_queryparam(date_max):
qs = qs.filter(prog_data_ini__lt=date_max)
html
德斯德:
哈斯塔:
<div class="input-group date">
<b class="b-form">DESDE:</b><input type="date" class="form-control" id="publishDateMin" name="date_min" value="{{format_min}}">
<span class="input-group-addon">
<i class="glyphicon glyphicon-th"></i>
</span>
</div>
<div class="input-group date">
<b class="b-form">HASTA: </b>
<input type="date" class="form-control" id="publishDateMax" name="date_max" value="{{format_max}}">
<span class="input-group-addon">
<i class="glyphicon glyphicon-th"></i>
</span>
</div>