我正在尝试在创建的数据时间间隔之间计算数据。
我试过下面的代码
$check->where( function( $exp, $q ) {
return $exp->between(
$q->newExpr( 'NOW()' ),
$q->newExpr( 'created' ),
$q->newExpr( 'DATE_ADD( created, INTERVAL 30 MINUTE )' )
);
} );
我也试过
$check->where( [
'TIMESTAMPDIFF( MINUTE, created, NOW() ) >=' => 1,
'TIMESTAMPDIFF( MINUTE, created, NOW() ) <=' => 30,
] );
两次我得到结果0
但如果我尝试使用debug.log查询,我会得到结果1
SELECT (COUNT(*)) AS count FROM money_transfer_transactions MoneyTransferTransactions WHERE (user_id = 2 AND receiver_account_number = '01737810405' AND NOW() BETWEEN created AND DATE_ADD( created, INTERVAL 30 MINUTE ))
这里正确的答案是1.
我如何在两个日期时间间隔之间获得30分钟?