獲得當(dāng)前日期+時(shí)間(date + time)1.1 函數(shù):now()
相關(guān)函數(shù):current_timestamp(),localtime(),localtimestamp()
舉例說明:
2. 獲得當(dāng)前日期(date)
函數(shù):curdate()
相關(guān)函數(shù):current_date(),current_date
舉例說明:
3. 獲得當(dāng)前時(shí)間(time)
函數(shù):curtime()
相關(guān)函數(shù):current_time(),current_time
舉例說明
4. MySQL dayof…
函數(shù):dayofweek(), dayofmonth(), dayofyear()分別返回日期參數(shù),在一周、一月、一年中的位置。
舉例說明
set @dt = '2008-08-08';
select dayofweek(@dt); -- 6
select dayofmonth(@dt); -- 8
select dayofyear(@dt); -- 221
日期‘2008-08-08′ 是一周中的第6 天(1 = Sunday, 2 = Monday, …, 7 = Saturday)
一月中的第8 天;一年中的第221 天