如何解决数据库从两列中取最低的日期值并计算天数
我有两列记录日期和时间,列“DataDaInstauracao”和“DataDaDenuncia”。从这两列中,我需要获取“DataDaInstauracao”和“DataDaDenuncia”天中最短时间的日期,然后将天数显示在屏幕上。
表格:
我已经有一个公开的数据列表,我用它来获取已经组装的该表的列:
// --------- graficos com base na TR_CRIME_AUTOR ---------
public List<CrimeAutorModel> GetAllCrimeAutorModel()
{
using (IDbConnection cn = ConnectionAnaliseCriminal)
{
try
{
cn.open();
string query = "SELECT COD_CRIME_AUTOR"
+ ",DataDaDenuncia"
+ " FROM dbo.TR_CRIME_AUTOR"
+ " WHERE DT_EXCLUSAO_LOGICA IS NULL";
return cn.Query<CrimeAutorModel>(query).ToList();
}
finally
{
cn.Close();
}
}
}
public List<InqueritoModel> GetAllInqueritoModel()
{
using (IDbConnection cn = ConnectionAnaliseCriminal)
{
try
{
cn.open();
string query = "SELECT COD_INQUERITO"
+ ",DataDaInstauracao"
+ " FROM dbo.TP_INQUERITO"
+ " WHERE DT_EXCLUSAO_LOGICA IS NULL";
return cn.Query<InqueritoModel>(query).ToList();
}
finally
{
cn.Close();
}
}
}
而且我还在控制器上安装了 Ajax,它接收数据并使用它来传递 JS:
// --------- graficos com base na TR_CRIME_AUTOR ----------
[HttpGet] public JsonResult AjaxGetAllCrimeAutorModel() => Json(new DashboardDados().GetAllCrimeAutorModel());
// --------- graficos com base na TP_INQUERITO ----------
[HttpGet] public JsonResult AjaxGetAllInqueritoModel() => Json(new DashboardDados().GetAllInqueritoModel());
async function shortestTimeDays() {
let resultado,numberOfDays = 0;
//chama o método ajax que trás todos os objetos
try {
const resposta = await fetch(`/Dashboard/AjaxGetAllCrimeAutorModel`);
resultado = await resposta.json();
} catch (e) {
console.error("Erro ao realizar fetch");
return console.error(e);
}
try {
const resposta = await fetch(`/Dashboard/AjaxGetAllInqueritoModel`);
resultado = await resposta.json();
} catch (e) {
console.error("Erro ao realizar fetch");
return console.error(e);
}
}
现在我想知道我应该如何使用 javascript 来实现我的目标并能够在屏幕上播放结果。
<div class="blocoprocessos" style="margin-bottom: 2em;">
<div style="width: 100%;text-align:center;">
<div>
<span style="font-size: 20px;font-weight: 400;">Tempo minimo fase pré-processual</span>
</div>
<hr class="hrBlocoprocesso" style="margin-bottom: 5px;margin-top: 10px;" />
<div style="display: flex;flex-direction: column;align-items: center;">
<span>Tempo (em dias)</span>
<span style="font-size: 25px;">*</span>
</div>
</div>
</div>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。