1. 程式人生 > >mysql 獲取昨天數據 utc時間

mysql 獲取昨天數據 utc時間

invite log creat ann channel eat val sub 字段

# yzj邀請昨日數據
SELECT s.id, s.create_at, ch.id, ch.code AS channel, c.id
	, c.code AS custom, so.id, so.code AS source
FROM invite_ship s
	LEFT JOIN invite_channel ch ON ch.id = s.invite_channel_id
	LEFT JOIN invite_code_custom c ON c.id = s.code_custom_id
	LEFT JOIN invite_source so ON s.invite_source_id = so.id
WHERE s.invite_source_id != 0
	AND s.create_at > date_sub(date_sub(curdate(), INTERVAL 1 DAY), INTERVAL 8 HOUR)
	AND s.create_at < date_sub(curdate(), INTERVAL 8 HOUR)
ORDER BY s.id DESC

  此處 s.create_at是時間字段, 如果你庫裏存的是utc時間 用這條sql邏輯準沒錯

mysql 獲取昨天數據 utc時間