我只想将此 MySql 查询更改为 Laravel 查询构建器:
SELECT * FROM domain_reg_infos WHERE d_expiryDate BETWEEN NOW() AND NOW() + INTERVAL 1 MONTH
我已经搜索过它,但找不到任何解决方案。请给我正确的解决方案。
提前致谢。
答案 0 :(得分:0)
试试这个:
$now = date('Y-m-d H:i:s'); //get today's date
$newdate = date('Y-m-d H:i:s', strtotime ( '+1 month' , strtotime ( $now ) ) ); //add 1 month to $now
$domain_reg_infos = Domain_Reg_Info::whereBetween('expiryDate', array($now, $newdate))->get();
答案 1 :(得分:0)
这很容易尝试该代码。
DB::table('domain_reg_infos')
->whereRaw('d_expiryDate between NOW() and NOW() + INTERVAL 1 MONTH')
->get();
答案 2 :(得分:0)
我想你可以先设置当前日期并加1个月。然后在你的查询中使用它,如:
Data1 <- structure(list(A = c("a", "b", "c", "d"), B = c(1L, 6L, 5L, 3L
), C = c("a,b", "c,b", "b,c", "a,d")), .Names = c("A", "B", "C"
), class = "data.frame", row.names = c(NA, -4L))
Data2 <- data.frame(Col1 = c("a,c", "b,d", "a,a", "a,c"), stringsAsFactors=FALSE)
然后,
$current_time = strtotime("2010.12.11");
$one_month_interval = date("Y-m-d", strtotime("+1 month", $current_time));