我有一个包含三列的表,ID,SETTLE_DATE_TIME,STATUS。我试图选择昨天SETTLE_DATE_TIME
并且状态为'E'的数据。
SELECT *
FROM rev_acq_edcbatch
WHERE EDCBATCH_STATUS='E'
AND EDCBATCH_SETTLE_DATETIME = CURDATE() - INTERVAL 1 DAY;
没有检索到数据,但我的数据结算日期时间为2017-01-26 16:28:50.000
且状态为E.
答案 0 :(得分:1)
将current_date
功能与SELECT *
FROM rev_acq_edcbatch
WHERE EDCBATCH_STATUS='E'
AND EDCBATCH_SETTLE_DATETIME = subdate(current_date, 1)
一起使用。
SUBDATE
如果NOW()
是时间戳,请将EDCBATCH_SETTLE_DATETIME
功能与SELECT *
FROM rev_acq_edcbatch
WHERE EDCBATCH_STATUS='E'
AND EDCBATCH_SETTLE_DATETIME = subdate(NOW(), 1)
一起使用。
var city_id = $('#cities option[value="' + $('#cityName').val() + '"]').data('id');
console.log(city_id);
答案 1 :(得分:1)
我认为这应该有效:
SELECT * FROM rev_acq_edcbatch where EDCBATCH_STATUS='E' AND DATE(EDCBATCH_SETTLE_DATETIME) = DATEADD(day, -1, convert(date, GETDATE()))
答案 2 :(得分:0)
这应该有用。
SELECT * FROM rev_acq_edcbatch where EDCBATCH_STATUS='E' AND EDCBATCH_SETTLE_DATETIME = DATE_SUB(NOW(), INTERVAL 1 DAY) ;
答案 3 :(得分:0)
试试这个,其中<html>
<body>
Enter your name: <input type="text" id="fname" onkeypress="myFunction()">
<p>When you press key into the input field, a function is triggered add space after one char .</p>
<p>If you give space in text box,its two time display, but you can overcome it</p>
</body>
</html>
具有正确的日期时间格式sql。
EDCBATCH_SETTLE_DATETIME