....
....
....
WHERE (OrderDate BETWEEN CONVERT(SMALLDATETIME, '1/8/2013', 103)
AND CONVERT(SMALLDATETIME, '31/8/2013', 103))
AND (DATEPART(hh, OrderDate) BETWEEN 20 AND 23
OR DATEPART(hh, OrderDate) BETWEEN 0 AND 8)
OR (DATEPART(hh, OrderDate) = 19) AND (DATEPART(mi, OrderDate) >= 30)
Mysql
...
...
...
WHERE OrderDate BETWEEN STR_TO_DATE('2013-8-1', '%Y-%m-%d')
AND STR_TO_DATE('2013-8-31', '%Y-%m-%d')
AND (TIME(OrderDate) BETWEEN '19:30:00' AND '23:59:59'
OR TIME(OrderDate) BETWEEN '00:00:00' AND '8:00:00')
Date :
2013-09-04 13:54:20
By :
ห้ามตอบเกินวันละ 2 กระทู้
No. 2
Guest
แก้ไขของ mysql
Mysql
...
...
...
WHERE OrderDate BETWEEN STR_TO_DATE('2013-8-1', '%Y-%m-%d')
AND STR_TO_DATE('2013-8-31', '%Y-%m-%d')
AND (TIME(OrderDate) BETWEEN STR_TO_DATE('19:30', '%H:%i') AND STR_TO_DATE('23:59', '%H:%i')
OR TIME(OrderDate) BETWEEN STR_TO_DATE('00:00', '%H:%i') AND STR_TO_DATE('8:00', '%H:%i'))
....
....
....
WHERE (
OrderDate BETWEEN CONVERT(SMALLDATETIME, '1/8/2012', 103) AND CONVERT(SMALLDATETIME, '31/8/2013', 103)
) AND (
DATEPART(hh, OrderDate) >= 19 AND DATEPART(mi, OrderDate) >= 30 OR
DATEPART(hh, OrderDate) BETWEEN 0 AND 8
)
ปล. เงื่อนไขประมาณว่า x(a + b)
x = เงื่อนไขวันที่ 1/8/2012 - 31/8/2013
a = เงื่อนไขช่วงเวลา >= 19.30 (ก็คือ 19.30 - 0.00)
b = เงื่อนไขช่วงเวลา 0.00 - 8.00
Date :
2013-09-04 15:28:02
By :
ห้ามตอบเกินวันละ 2 กระทู้
No. 5
Guest
เอ่อ มันก็ผิดอีกแหละ แก้ไขๆ
SQL Server
....
....
....
WHERE (
OrderDate BETWEEN CONVERT(SMALLDATETIME, '1/8/2012', 103) AND CONVERT(SMALLDATETIME, '31/8/2013', 103)
) AND (
DATEPART(hh, OrderDate) = 19 AND DATEPART(mi, OrderDate) >= 30 OR
DATEPART(hh, OrderDate) BETWEEN 20 AND 23 OR
DATEPART(hh, OrderDate) BETWEEN 0 AND 8
)