sql date sql一般


start_date の型を確認

-----------------------------------------------------------------

use Carbon¥Carbon;

$today = Carbon::parse( 2012-9-5 23:26:11.123789 );

var_dump($today->day); // int(5)
var_dump($today->dayOfWeek); // int(3) 曜日。数値。0 (日曜)から 6 (土曜)
var_dump($today->weekOfMonth); // int(1) 月間の週番号。
--------------------------------------------------------------------------------


use Carbon¥Carbon;

//日本語の曜日配列
$weekjp = array(
日 //0
月 //1
火 //2
水 //3
木 //4
金 //5
土 //6
);
//現在の曜日番号(日:0 月:1 火:2 水:3 木:4 金:5 土:6)を取得


$today = Carbon::today()->toDateString(); // 2015-05-09
$dd = $today->day ; // 日
$youbi = $weekjp[$today->dayOfWeek] ; // 曜日
$week_no = $today->weekOfMonth ; // 月間の週番号。

----------
http://blog.asial.co.jp/1392
----------

select * from where exclusion_settings

where start_datetime <= . &#36;today .
and end_datetime >= . &#36;today .
and
(
( repeat_contidion = 0 and repeat_contidion_value = 0 )
or
( repeat_contidion = 1 and repeat_contidion_value = 0 )
or
( repeat_contidion = 3 and repeat_contidion_value = 1-31 ) ←★日 &#36;dd
or
( repeat_contidion = 2 and repeat_contidion_value = 日月火水木金土 ) ←★曜日 &#36;youbi
or
( repeat_contidion = 21-25 2 and repeat_contidion_value = 日月火水木金土 ) ←★曜日 &#36;week_no &#36;youbi
) &#36;week_no
-----------------------------------------------------------------