Como puedo calcular la edad automaticamente
Como puedo calcular la edad automaticamente
Danirom
Posts: 1Questions: 1Answers: 0
Hello, how are you, could someone help me to solve this problem please. I want to calculate the age from the fechanac column (date of birth). The age column is not a data that I get from the query that I make through ajax. Thank you very much.
tabla = $('#table_id').DataTable({
/*"destroy": true,*/
"processing": true,
"serverSide": true,
"ajax": {
"url": "/Pacientes/GetPacientes",
"type": "POST",
"datatype": "json"
},
"bInfo": false,
"pageLength": 10,
"filter": true,
"responsive": true,
"responsivePriority": 1,
"data": null,
"columns": [
{ "data": "codigo", "name": "codigo", "autoWidth": true, "visible": false },
{ "data": "dni", "name": "dni", "autoWidth": true },
{ "data": "paciente", "name": "paciente", "autoWidth": true },
{ "data": "histclinica", "name": "hisclinica", "autoWidth": true },
{ "data": "fechanac", "name": "fechanac", "autoWidth": true },
{ "name": "edad" },
{ "data": "sexo", "name": "sexo", "autoWidth": true },
{ "data": "peso", "name": "peso", "autoWidth": true },
{ "data": "talla", "name": "talla", "autoWidth": true },
{ "data": "direccion", "name": "direccion", "autoWidth": true },
{ "data": "localidad", "name": "localidad", "autoWidth": true },
{ "data": "provincia", "name": "provincia", "autoWidth": true },
{ "data": "profesion", "name": "profesion", "autoWidth": true },
{ "data": "celular", "name": "celular", "autoWidth": true },
{ "data": "mail", "name": "mail", "autoWidth": true },
{ "data": "responsable", "name": "responsable", "autoWidth": true },
{ "data": "fallecio", "name": "fallecio", "autoWidth": true },
{ "defaultContent": "<button type='button' value='Seleccionar' title='Actualizar Datos del Paciente' class='btn btn-secondary btn-modificar'><i class='bi bi-file-earmark-text' aria-hidden='true'></i></button>" },
{ "defaultContent": "<button type='button' value='Seleccionar' title='Eliminar Paciente' class='btn btn-default btn-eliminarpaciente'><i class='bi bi-trash' aria-hidden='true'></i></button>" },
{ "defaultContent": "<button type='button' value='Seleccionar' title='Obra Sociales del Paciente' class='btn btn-default btn-mutual'><i class='bi bi-file-earmark-plus' aria-hidden='true'></i></button>" }
],
This discussion has been closed.
Answers
Use
columns.render
to calculate the age from thefallecia
column. Similar to this example except instead of concatenating two strings you would perform your age calculation.Kevin