0
Good afternoon,
I’m using data-Picker and I’m having trouble filtering by dates.
1 Error : The code returns me in mm/dd/YYY even with format due to line: var min = $('#min'). datepicker("getDate");
Would need it to return (dd-mm-YYYY) in format;
My js that filters:
$.fn.dataTable.ext.search.push(
function (settings, data, dataIndex) {
var min = $('#min').datepicker("getDate");
var max = $('#max').datepicker("getDate");
console.log(max);
var startDate = new Date(data[7]);
if (min == null && max == null) { return true; }
if (min == null && startDate <= max) { return true;}
if(max == null && startDate >= min) {return true;}
if (startDate <= max && startDate >= min) { return true; }
return false;
}
);
My js of datapicker:
$("#min").datepicker({
onSelect: function () {
table.draw();
},
weekStart: 0,
format: 'dd/mm/yyyy',
language: 'pt-BR',
time: false
});
$("#max").datepicker({
format: 'dd/mm/yyyy',
changeMonth: true,
changeYear: true,
onSelect: function () {
table.draw();
},
});
$('#min, #max').change(function () {
table.draw();
});
My js from
var table = "";
table = $('#aportes-table').DataTable({
"language" : {
"sEmptyTable": "Nenhum registro encontrado",
"sInfo": "Mostrando _START_ até _END_ de _TOTAL_ Resultados",
"sInfoEmpty": "Mostrando 0 até 0 de 0 registros",
"sInfoFiltered": "(Filtrados de MAX registros)",
"sInfoPostFix": "",
"sInfoThousands": ".",
"sLengthMenu": "_MENU_ resultados por página",
"sLoadingRecords": "Carregando...",
"sProcessing": "Processando...",
"sZeroRecords": "Nenhum registro encontrado",
"sSearch": "Pesquisar",
"oPaginate": {
"sNext": "Próximo",
"sPrevious": "Anterior",
"sFirst": "Primeiro",
"sLast": "Último"
},
"oAria": {
"sSortAscending": ": Ordenar colunas de forma ascendente",
"sSortDescending": ": Ordenar colunas de forma descendente"
}
},
dom: 'Bfrtip',
buttons: [
'copyHtml5',
'excelHtml5',
'csvHtml5',
],
});
have you tried it? #Xa;
var min = $.datepicker.formatDate("dd-mm-YYYY", $("#min").datepicker("getDate"));
– Ricardo Pontual