GETDATE()用于MsSQL。使用NOW()表示当前日期时间,使用curdate()表示当前日期。
今年迄今:
SELECT coins_daily_date, coins_daily_high, coins_daily_low, coins_daily_close,
coins_daily_volume
FROM coins_daily
WHERE YEAR(coins_daily_date) = YEAR(NOW())
AND coins_daily_date <= NOW()
ORDER BY coins_daily_date ASC
SELECT coins_daily_date, coins_daily_high, coins_daily_low, coins_daily_close,
coins_daily_volume
FROM coins_daily
WHERE YEAR(coins_daily_date) = YEAR(NOW())
AND MONTH(coins_daily_date) = MONTH(NOW())
AND coins_daily_date <= NOW()
ORDER BY coins_daily_date ASC
本周迄今:
SELECT coins_daily_date, coins_daily_high, coins_daily_low, coins_daily_close,
coins_daily_volume
FROM coins_daily
WHERE YEAR(coins_daily_date) = YEAR(NOW())
AND WEEK(coins_daily_date) = WEEK(NOW())
AND coins_daily_date <= NOW()
ORDER BY coins_daily_date ASC