在我的数据库中,我得到一个日期。 日期=每15分钟返回一次值
我需要在特定时间获取值。每天这个时间是21:45。
我已经尝试创建返回DateTime的值,然后在sql语句中说BETWEEN 日期的格式如下: 2019-06-27 10:30:00.000
DateTime dateFrom = DateTime.Now.AddDays(-15).AddHours(-DateTime.Now.Hour);
DateTime dateTo = DateTime.Now.AddDays(-15).AddHours(-DateTime.Now.Hour + 22);
//there I open an connection to my Database /Measurement/
var measurements = connection.Query<Measurement>(SQLMeasurement.GetPreviousMaxValue, new { dateFrom = dateFrom, dateTo = dateTo} );
select f.[Name], m.MeasurementDate, m.MeasurementValue
FROM Facility f
JOIN Measurement m
ON f.Id = m.FacilityId
WHERE m.MeasurementDate BETWEEN @dateFrom and @dateTo
GROUP BY f.[Name], m.MeasurementDate, m.MeasurementValue;