SQLµ±Ç°ÈÕÆÚ»ñÈ¡¼¼ÇÉ
select getdate() //2003-11-07 17:21:08.597
select convert(varchar(10), getdate(),120) //2003-11-07
select convert(char(8),getdate(),112) //20031107
select convert(char(8),getdate(),108) //17:22:18
select datepart(year,getdate()) //2007
µ±Ç°ÈÕÆÚ
select CONVERT(varchar(10), getdate(), 120)
Ò»¸öÔµÚÒ»ÌìµÄSQL ½Å±¾£º
SELECT DATEADD(mm, DATEDIFF(mm,0,getdate()), 0)
±¾ÖܵÄÐÇÆÚÒ»
SELECT DATEADD(wk, DATEDIFF(wk,0,getdate()), 0)
Ò»ÄêµÄµÚÒ»Ìì
SELECT DATEADD(yy, DATEDIFF(yy,0,getdate()), 0)
¼¾¶ÈµÄµÚÒ»Ìì
SELECT DATEADD(qq, DATEDIFF(qq,0,getdate()), 0)
µ±ÌìµÄ°ëÒ¹
SELECT DATEADD(dd, DATEDIFF(dd,0,getdate()), 0)
ÉϸöÔµÄ×îºóÒ»Ìì
SELECT dateadd(ms,-3,DATEADD(mm, DATEDIFF(mm,0,getdate()), 0))
È¥ÄêµÄ×îºóÒ»Ìì
SELECT dateadd(ms,-3,DATEADD(yy, DATEDIFF(yy,0,getdate()), 0))
±¾ÔµÄ×îºóÒ»Ìì
SELECT dateadd(ms,-3,DATEADD(mm, DATEDIFF(m,0,getdate())+1, 0))
±¾ÄêµÄ×îºóÒ»Ìì
SELECT dateadd(ms,-3,DATEADD(yy, DATEDIFF(yy,0,getdate())+1, 0))¡£
±¾ÔµĵÚÒ»¸öÐÇÆÚÒ»
select DATEADD(wk, DATEDIFF(wk,0,
dateadd(dd,6-datepart(day,getdate()),getdate())
&nb
»Ö¸´Ä£Ê½£¨Recovery Model£©Ö¼ÔÚ¿ØÖÆÊÂÎñÈÕ־ά»¤¡£»Ö¸´Ä£Ê½ËµÃ÷Á˹¤×÷¶ªÊ§µÄ·çÏÕ£¬ÄÜ·ñ»Ö¸´µ½Ê±µã£¿
SQL ServerÊý¾Ý¿âÓÐÈýÖÖ»Ö¸´Ä£Ê½£º¼òµ¥»Ö¸´Ä£Ê½¡¢ÍêÕû»Ö¸´Ä£Ê½ºÍ´óÈÝÁ¿ÈÕÖ¾»Ö¸´Ä£Ê½¡£
Ïà¶ÔÓÚ¼òµ¥»Ö¸´Ä£Ê½¶øÑÔ£¬ÍêÕû»Ö¸´Ä£Ê½ºÍ´óÈÝÁ¿ÈÕÖ¾»Ö¸´Ä£Ê½ÌṩÁ˸üÇ¿µÄÊý¾Ý±£»¤¹¦ÄÜ¡£ÕâЩ»Ö¸´Ä£Ê½¶¼ÊÇ»ùÓÚ±¸·ÝÊÂÎñÈÕÖ ......